libxls / libxls

Read binary Excel files from C/C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

large SummaryInformation causes crash

aaronberney opened this issue · comments

A crash occurs if the summaryinformation is larger than 4k. This modification sorted it for me.

if ((pWB->olestr=ole2_fopen(ole, "\005SummaryInformation")))
{
int iSize = pWB->olestr->size;
pWB->summary = calloc(1, iSize);
int nBytesRead = ole2_read(pWB->summary, iSize, 1, pWB->olestr);
if (nBytesRead == -1)
{
if (xls_debug) fprintf(stderr, "SummaryInformation not found\n");
retval = LIBXLS_ERROR_READ;
goto cleanup;
}
ole2_fclose(pWB->olestr);
}

if ((pWB->olestr=ole2_fopen(ole, "\005DocumentSummaryInformation")))
{
int iSize = pWB->olestr->size;
pWB->docSummary = calloc(1, iSize);
int nBytesRead = ole2_read(pWB->docSummary, iSize, 1, pWB->olestr);
if (nBytesRead == -1)
{
if (xls_debug) fprintf(stderr, "DocumentSummaryInformation not found\n");
retval = LIBXLS_ERROR_READ;
goto cleanup;
}
ole2_fclose(pWB->olestr);
}

Would you mind preparing a pull request?