mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-12-27 21:58:22 +01:00
Compare commits
3 Commits
6cb661f0f4
...
206f75403a
Author | SHA1 | Date | |
---|---|---|---|
|
206f75403a | ||
|
7d22477917 | ||
|
7c3651671b |
@ -6,6 +6,7 @@ v1.3.2 - YYYY-MM-DD
|
|||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
- Added some more sanity checks to the TrueType font reader.
|
- Added some more sanity checks to the TrueType font reader.
|
||||||
|
- Fixed an issue when opening certain encrypted PDF files (Issue #62)
|
||||||
|
|
||||||
|
|
||||||
v1.3.1 - 2024-08-05
|
v1.3.1 - 2024-08-05
|
||||||
|
@ -363,6 +363,9 @@ _pdfioArrayDebug(pdfio_array_t *a, // I - Array
|
|||||||
_pdfio_value_t *v; // Current value
|
_pdfio_value_t *v; // Current value
|
||||||
|
|
||||||
|
|
||||||
|
if (!a)
|
||||||
|
return;
|
||||||
|
|
||||||
putc('[', fp);
|
putc('[', fp);
|
||||||
for (i = a->num_values, v = a->values; i > 0; i --, v ++)
|
for (i = a->num_values, v = a->values; i > 0; i --, v ++)
|
||||||
_pdfioValueDebug(v, fp);
|
_pdfioValueDebug(v, fp);
|
||||||
|
@ -194,6 +194,9 @@ _pdfioDictDebug(pdfio_dict_t *dict, // I - Dictionary
|
|||||||
_pdfio_pair_t *pair; // Current pair
|
_pdfio_pair_t *pair; // Current pair
|
||||||
|
|
||||||
|
|
||||||
|
if (!dict)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = dict->num_pairs, pair = dict->pairs; i > 0; i --, pair ++)
|
for (i = dict->num_pairs, pair = dict->pairs; i > 0; i --, pair ++)
|
||||||
{
|
{
|
||||||
fprintf(fp, "/%s", pair->key);
|
fprintf(fp, "/%s", pair->key);
|
||||||
|
22
pdfio-file.c
22
pdfio-file.c
@ -188,6 +188,8 @@ pdfioFileCreate(
|
|||||||
int fd; // File descriptor
|
int fd; // File descriptor
|
||||||
|
|
||||||
|
|
||||||
|
PDFIO_DEBUG("pdfioFileCreate(filename=\"%s\", version=\"%s\", media_box=%p, crop_box=%p, error_cb=%p, error_cbdata=%p)\n", filename, version, (void *)media_box, (void *)crop_box, (void *)error_cb, (void *)error_cbdata);
|
||||||
|
|
||||||
// Range check input...
|
// Range check input...
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -390,6 +392,8 @@ pdfioFileCreateOutput(
|
|||||||
pdfio_error_cb_t error_cb, // I - Error callback or `NULL` for default
|
pdfio_error_cb_t error_cb, // I - Error callback or `NULL` for default
|
||||||
void *error_cbdata) // I - Error callback data, if any
|
void *error_cbdata) // I - Error callback data, if any
|
||||||
{
|
{
|
||||||
|
PDFIO_DEBUG("pdfioFileCreate(output_cb=%p, output_cbdata=%p, version=\"%s\", media_box=%p, crop_box=%p, error_cb=%p, error_cbdata=%p)\n", (void *)output_cb, (void *)output_cbdata, version, (void *)media_box, (void *)crop_box, (void *)error_cb, (void *)error_cbdata);
|
||||||
|
|
||||||
return (create_common("output.pdf", /*fd*/-1, output_cb, output_cbdata, version, media_box, crop_box, error_cb, error_cbdata));
|
return (create_common("output.pdf", /*fd*/-1, output_cb, output_cbdata, version, media_box, crop_box, error_cb, error_cbdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,6 +528,8 @@ pdfioFileCreateTemporary(
|
|||||||
unsigned tmpnum; // Temporary filename number
|
unsigned tmpnum; // Temporary filename number
|
||||||
|
|
||||||
|
|
||||||
|
PDFIO_DEBUG("pdfioFileCreate(buffer=%p, bufsize=%lu, version=\"%s\", media_box=%p, crop_box=%p, error_cb=%p, error_cbdata=%p)\n", (void *)buffer, (unsigned long)bufsize, version, (void *)media_box, (void *)crop_box, (void *)error_cb, (void *)error_cbdata);
|
||||||
|
|
||||||
// Range check input...
|
// Range check input...
|
||||||
if (!buffer || bufsize < 32)
|
if (!buffer || bufsize < 32)
|
||||||
{
|
{
|
||||||
@ -648,11 +654,12 @@ pdfioFileFindObj(
|
|||||||
if ((current = number - 1) >= pdf->num_objs)
|
if ((current = number - 1) >= pdf->num_objs)
|
||||||
current = pdf->num_objs / 2;
|
current = pdf->num_objs / 2;
|
||||||
|
|
||||||
PDFIO_DEBUG("pdfioFileFindObj: objs[current=%lu]=%p\n", (unsigned long)current, (void *)pdf->objs[current]);
|
PDFIO_DEBUG("pdfioFileFindObj: objs[current=%lu]=%p(%lu)\n", (unsigned long)current, (void *)pdf->objs[current], (unsigned long)(pdf->objs[current] ? pdf->objs[current]->number : 0));
|
||||||
|
|
||||||
if (number == pdf->objs[current]->number)
|
if (number == pdf->objs[current]->number)
|
||||||
{
|
{
|
||||||
// Fast match...
|
// Fast match...
|
||||||
|
PDFIO_DEBUG("pdfioFileFindObj: Returning %lu (%p)\n", (unsigned long)current, pdf->objs[current]);
|
||||||
return (pdf->objs[current]);
|
return (pdf->objs[current]);
|
||||||
}
|
}
|
||||||
else if (number < pdf->objs[current]->number)
|
else if (number < pdf->objs[current]->number)
|
||||||
@ -679,11 +686,20 @@ pdfioFileFindObj(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (number == pdf->objs[left]->number)
|
if (number == pdf->objs[left]->number)
|
||||||
|
{
|
||||||
|
PDFIO_DEBUG("pdfioFileFindObj: Returning %lu (%p)\n", (unsigned long)left, pdf->objs[left]);
|
||||||
return (pdf->objs[left]);
|
return (pdf->objs[left]);
|
||||||
|
}
|
||||||
else if (number == pdf->objs[right]->number)
|
else if (number == pdf->objs[right]->number)
|
||||||
|
{
|
||||||
|
PDFIO_DEBUG("pdfioFileFindObj: Returning %lu (%p)\n", (unsigned long)right, pdf->objs[right]);
|
||||||
return (pdf->objs[right]);
|
return (pdf->objs[right]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
PDFIO_DEBUG("pdfioFileFindObj: Returning NULL\n");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -928,6 +944,8 @@ pdfioFileOpen(
|
|||||||
off_t xref_offset; // Offset to xref table
|
off_t xref_offset; // Offset to xref table
|
||||||
|
|
||||||
|
|
||||||
|
PDFIO_DEBUG("pdfioFileOpen(filename=\"%s\", password_cb=%p, password_cbdata=%p, error_cb=%p, error_cbdata=%p)\n", filename, (void *)password_cb, (void *)password_cbdata, (void *)error_cb, (void *)error_cbdata);
|
||||||
|
|
||||||
// Range check input...
|
// Range check input...
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -1285,6 +1303,8 @@ create_common(
|
|||||||
unsigned char id_value[16]; // File ID value
|
unsigned char id_value[16]; // File ID value
|
||||||
|
|
||||||
|
|
||||||
|
PDFIO_DEBUG("create_common(filename=\"%s\", fd=%d, output_cb=%p, output_cbdata=%p, version=\"%s\", media_box=%p, crop_box=%p, error_cb=%p, error_cbdata=%p)\n", filename, fd, (void *)output_cb, (void *)output_cbdata, version, (void *)media_box, (void *)crop_box, (void *)error_cb, (void *)error_cbdata);
|
||||||
|
|
||||||
// Range check input...
|
// Range check input...
|
||||||
if (!filename || (fd < 0 && !output_cb))
|
if (!filename || (fd < 0 && !output_cb))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -408,6 +408,7 @@ _pdfioStreamOpen(pdfio_obj_t *obj, // I - Object
|
|||||||
pdfio_stream_t *st; // Stream
|
pdfio_stream_t *st; // Stream
|
||||||
pdfio_dict_t *dict = pdfioObjGetDict(obj);
|
pdfio_dict_t *dict = pdfioObjGetDict(obj);
|
||||||
// Object dictionary
|
// Object dictionary
|
||||||
|
const char *type; // Object type
|
||||||
|
|
||||||
|
|
||||||
PDFIO_DEBUG("_pdfioStreamOpen(obj=%p(%u), decode=%s)\n", obj, (unsigned)obj->number, decode ? "true" : "false");
|
PDFIO_DEBUG("_pdfioStreamOpen(obj=%p(%u), decode=%s)\n", obj, (unsigned)obj->number, decode ? "true" : "false");
|
||||||
@ -434,7 +435,9 @@ _pdfioStreamOpen(pdfio_obj_t *obj, // I - Object
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj->pdf->encryption)
|
type = pdfioObjGetType(obj);
|
||||||
|
|
||||||
|
if (obj->pdf->encryption && (!type || strcmp(type, "XRef")))
|
||||||
{
|
{
|
||||||
uint8_t iv[64]; // Initialization vector
|
uint8_t iv[64]; // Initialization vector
|
||||||
size_t ivlen; // Length of initialization vector, if any
|
size_t ivlen; // Length of initialization vector, if any
|
||||||
@ -1069,11 +1072,6 @@ stream_read(pdfio_stream_t *st, // I - Stream
|
|||||||
_pdfioFileError(st->pdf, "Unable to decompress stream data for object %ld: %s", (long)st->obj->number, zstrerror(status));
|
_pdfioFileError(st->pdf, "Unable to decompress stream data for object %ld: %s", (long)st->obj->number, zstrerror(status));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
else if (avail_in == st->flate.avail_in && avail_out == st->flate.avail_out)
|
|
||||||
{
|
|
||||||
_pdfioFileError(st->pdf, "Corrupt stream data.");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (st->flate.next_out - (Bytef *)buffer);
|
return (st->flate.next_out - (Bytef *)buffer);
|
||||||
}
|
}
|
||||||
|
@ -215,6 +215,9 @@ void
|
|||||||
_pdfioValueDebug(_pdfio_value_t *v, // I - Value
|
_pdfioValueDebug(_pdfio_value_t *v, // I - Value
|
||||||
FILE *fp) // I - Output file
|
FILE *fp) // I - Output file
|
||||||
{
|
{
|
||||||
|
if (!v)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (v->type)
|
switch (v->type)
|
||||||
{
|
{
|
||||||
case PDFIO_VALTYPE_ARRAY :
|
case PDFIO_VALTYPE_ARRAY :
|
||||||
|
Loading…
Reference in New Issue
Block a user