mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-11-07 22:18:27 +01:00
Show an error when opening an encrypted PDF file.
This commit is contained in:
parent
6aa5585eb4
commit
b2db43afcb
18
pdfio-file.c
18
pdfio-file.c
@ -1166,7 +1166,7 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
|
||||
|
||||
PDFIO_DEBUG("load_xref: xref_offset=%lu, line='%s'\n", (unsigned long)xref_offset, line);
|
||||
|
||||
if (isdigit(line[0] & 255) && strlen(line) > 4 && !strcmp(line + strlen(line) - 4, " obj"))
|
||||
if (isdigit(line[0] & 255) && strlen(line) > 4 && (!strcmp(line + strlen(line) - 4, " obj") || ((ptr = strstr(line, " obj")) != NULL && ptr[4] == '<')))
|
||||
{
|
||||
// Cross-reference stream
|
||||
pdfio_obj_t *obj; // Object
|
||||
@ -1201,12 +1201,14 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
|
||||
while (isspace(*ptr & 255))
|
||||
ptr ++;
|
||||
|
||||
if (strcmp(ptr, "obj"))
|
||||
if (strncmp(ptr, "obj", 3))
|
||||
{
|
||||
_pdfioFileError(pdf, "Bad xref table header '%s'.", line);
|
||||
return (false);
|
||||
}
|
||||
|
||||
_pdfioFileSeek(pdf, xref_offset + ptr + 3 - line, SEEK_SET);
|
||||
|
||||
PDFIO_DEBUG("load_xref: Loading object %lu %u.\n", (unsigned long)number, (unsigned)generation);
|
||||
|
||||
if ((obj = add_obj(pdf, (size_t)number, (unsigned short)generation, xref_offset)) == NULL)
|
||||
@ -1227,6 +1229,12 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
|
||||
_pdfioFileError(pdf, "Cross-reference stream does not have a dictionary.");
|
||||
return (false);
|
||||
}
|
||||
else if (_pdfioDictGetValue(pdf->trailer, "Encrypt"))
|
||||
{
|
||||
// Encryption not yet supported...
|
||||
_pdfioFileError(pdf, "Sorry, PDFio currently does not support encrypted PDF files.");
|
||||
return (false);
|
||||
}
|
||||
|
||||
obj->value = trailer;
|
||||
|
||||
@ -1468,6 +1476,12 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
|
||||
_pdfioFileError(pdf, "Trailer is not a dictionary.");
|
||||
return (false);
|
||||
}
|
||||
else if (_pdfioDictGetValue(pdf->trailer, "Encrypt"))
|
||||
{
|
||||
// Encryption not yet supported...
|
||||
_pdfioFileError(pdf, "Sorry, PDFio currently does not support encrypted PDF files.");
|
||||
return (false);
|
||||
}
|
||||
|
||||
_pdfioTokenFlush(&tb);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user