mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2025-07-13 06:24:25 +02:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
b23dbd81c1 | |||
3c7a980a0b | |||
019c05d04a | |||
7ab550254a | |||
fa8e54cca2 | |||
d92fcb7bfb | |||
001dcbb123 | |||
a431d7806f | |||
ec8e900ea5 | |||
c73aa7ae20 | |||
c53786e0e1 |
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1,2 +1,4 @@
|
||||
.git* export-ignore
|
||||
afl-pdf.dict export-ignore
|
||||
afl-input export-ignore
|
||||
makesrcdist export-ignore
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,6 +4,7 @@
|
||||
*.o
|
||||
*.so.1
|
||||
/.vs
|
||||
/afl-output
|
||||
/doc/pdfio.epub
|
||||
/packages
|
||||
/pdfio.xcodeproj/xcshareddata
|
||||
|
@ -2,6 +2,12 @@ Changes in PDFio
|
||||
================
|
||||
|
||||
|
||||
v1.0rc1 (Month DD, YYYY)
|
||||
------------------------
|
||||
|
||||
- Fixed a few stack/buffer overflow bugs discovered via fuzzing.
|
||||
|
||||
|
||||
v1.0b2 (November 7, 2021)
|
||||
-------------------------
|
||||
|
||||
@ -10,6 +16,7 @@ v1.0b2 (November 7, 2021)
|
||||
- Fixed `all-shared` target (Issue #22)
|
||||
- Fixed memory leaks (Issue #23)
|
||||
- Updated `pdfioContentSetDashPattern` to accept `double` values (Issue #25)
|
||||
- Added support for reading and writing encrypted PDFs (Issue #26)
|
||||
- Fixed some issues identified by a Coverity scan.
|
||||
|
||||
|
||||
|
17
Makefile
17
Makefile
@ -16,8 +16,8 @@ ARFLAGS = cr
|
||||
CC = cc
|
||||
CFLAGS =
|
||||
CODESIGN_IDENTITY = Developer ID
|
||||
#COMMONFLAGS = -Os -g
|
||||
COMMONFLAGS = -O0 -g
|
||||
COMMONFLAGS = -Os -g
|
||||
#COMMONFLAGS = -O0 -g -fsanitize=address
|
||||
CPPFLAGS = '-DPDFIO_VERSION="$(VERSION)"'
|
||||
DESTDIR = $(DSTROOT)
|
||||
DSO = cc
|
||||
@ -26,7 +26,7 @@ DSONAME =
|
||||
LDFLAGS =
|
||||
LIBS = -lm -lz
|
||||
RANLIB = ranlib
|
||||
VERSION = 1.0b2
|
||||
VERSION = 1.0rc1
|
||||
prefix = /usr/local
|
||||
|
||||
|
||||
@ -160,8 +160,7 @@ testpdfio: testpdfio.o libpdfio.a
|
||||
|
||||
|
||||
# Dependencies
|
||||
$(OBJS): pdfio.h Makefile
|
||||
$(LIBOBJS): pdfio-private.h
|
||||
$(OBJS): pdfio.h pdfio-private.h Makefile
|
||||
pdfio-content.o: pdfio-content.h ttf.h
|
||||
ttf.o: ttf.h
|
||||
|
||||
@ -179,6 +178,14 @@ doc:
|
||||
rm -f pdfio.xml
|
||||
|
||||
|
||||
# Fuzz-test the library <>
|
||||
.PHONY: afl
|
||||
afl:
|
||||
$(MAKE) -$(MAKEFLAGS) CC="afl-clang-fast" COMMONFLAGS="-g" clean all
|
||||
test afl-output || rm -rf afl-output
|
||||
afl-fuzz -x afl-pdf.dict -i afl-input -o afl-output -V 600 -e pdf -t 5000 ./testpdfio @@
|
||||
|
||||
|
||||
# Analyze code with the Clang static analyzer <https://clang-analyzer.llvm.org>
|
||||
clang:
|
||||
clang $(CPPFLAGS) --analyze $(OBJS:.o=.c) 2>clang.log
|
||||
|
@ -3,7 +3,7 @@ pdfio - PDF Read/Write Library
|
||||
|
||||

|
||||

|
||||

|
||||
[](https://github.com/michaelrsweet/pdfio/actions/workflows/build.yml)
|
||||
[](https://scan.coverity.com/projects/michaelrsweet-pdfio)
|
||||
[](https://lgtm.com/projects/g/michaelrsweet/pdfio/context:cpp)
|
||||
[](https://lgtm.com/projects/g/michaelrsweet/pdfio/)
|
||||
|
BIN
afl-input/PDFBOX-1010-0.pdf
Normal file
BIN
afl-input/PDFBOX-1010-0.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1018-0.pdf
Normal file
BIN
afl-input/PDFBOX-1018-0.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1023-2.pdf
Normal file
BIN
afl-input/PDFBOX-1023-2.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1029-0.pdf
Normal file
BIN
afl-input/PDFBOX-1029-0.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1036-0.pdf
Normal file
BIN
afl-input/PDFBOX-1036-0.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1036-2.pdf
Normal file
BIN
afl-input/PDFBOX-1036-2.pdf
Normal file
Binary file not shown.
55
afl-input/PDFBOX-1037-0.pdf
Normal file
55
afl-input/PDFBOX-1037-0.pdf
Normal file
@ -0,0 +1,55 @@
|
||||
%PDF-1.3
|
||||
1 0 obj<</Type/Catalog/Pages 5 0 R>>
|
||||
endobj
|
||||
3 0 obj<</ModDate(D:20110505091515-05'00')/CreationDate(2011/05/05 09:15)/Creator(PaperPort 11.0)/Producer(PaperPort 11.0)/Subject()/Author()/Keywords()/Title()>>
|
||||
endobj
|
||||
4 0 obj<</Type/Page/MediaBox[0 0 622.0799 756]/Parent 5 0 R/CropBox[0 0 622.0799 756]/Contents 7 0 R/Resources<</ProcSet[/PDF/Text/ImageB/ImageC/ImageI]/XObject<</Z_Im0 6 0 R>>>>>>
|
||||
endobj
|
||||
5 0 obj<</Count 1/Type/Pages/Kids[ 4 0 R]>>
|
||||
endobj
|
||||
6 0 obj<</Type/XObject/Subtype/Image/Name/XImg/Width 1728/Height 2100/BitsPerComponent 1/ColorSpace/DeviceGray/Intent//Filter[/CCITTFaxDecode]/DecodeParms[<</Colors 1/Columns 1728/Rows 2100/K -1>>]/Length 81592>>stream
|
||||
endstream
|
||||
endobj
|
||||
7 0 obj<</Length 72>>stream
|
||||
q
|
||||
622.07996 0 0 756 0 0 cm
|
||||
0 g
|
||||
[]0 d 1 w 10 M 0 i 0 J 0 j
|
||||
/Z_Im0 Do
|
||||
Q
|
||||
|
||||
endstream
|
||||
endobj
|
||||
xref
|
||||
0 8
|
||||
0000000002 65535 f
|
||||
0000000010 00000 n
|
||||
0000000000 00000 f
|
||||
0000000054 00000 n
|
||||
0000000224 00000 n
|
||||
0000000412 00000 n
|
||||
0000000463 00000 n
|
||||
0000082294 00000 n
|
||||
trailer
|
||||
<</Size 8/Info 3 0 R/Root 1 0 R/ID[<c48c2a5922382dc456a05f8e3ccbb9f8><94a076a2f82a754598b70200e827ac8b>]>>
|
||||
startxref
|
||||
82414
|
||||
%%EOF
|
||||
%PaperPortPDFversion3 0 obj<</ModDate(D:20110505091515-05'00')/CreationDate(2011/05/05 09:15)/Creator(PaperPort 11.0)/Producer(PaperPort 11.0)/Subject()/Author()/Keywords()/Title()>>
|
||||
endobj
|
||||
5 0 obj<</Count 2/Type/Pages/Kids[ 4 0 R 8 0 R]>>
|
||||
endobj
|
||||
8 0 obj<</Type/Page/MediaBox[0 0 622.0799 757.4399]/Parent 5 0 R/CropBox[0 0 622.0799 757.4399]/Contents 10 0 R/Resources<</ProcSet[/PDF/Text/ImageB/ImageC/ImageI]/XObject<</Z_Im0 9 0 R>>>>>>
|
||||
endobj
|
||||
9 0 obj<</Type/XObject/Subtype/Image/Name/XImg/Width 1728/Height 2104/BitsPerComponent 1/ColorSpace/DeviceGray/Intent//Filter[/CCITTFaxDecode]/DecodeParms[<</Colors 1/Columns 1728/Rows 2104/K -1>>]/Length 78404>>stream
|
||||
endstream
|
||||
endobj
|
||||
10 0 obj<</Length 78>>stream
|
||||
q
|
||||
622.07996 0 0 757.44001 0 0 cm
|
||||
0 g
|
||||
[]0 d 1 w 10 M 0 i 0 J 0 j
|
||||
/Z_Im0 Do
|
||||
Q
|
||||
|
||||
endstream
|
BIN
afl-input/PDFBOX-1039-0.pdf
Normal file
BIN
afl-input/PDFBOX-1039-0.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1047-0.pdf
Normal file
BIN
afl-input/PDFBOX-1047-0.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1048-1.pdf
Normal file
BIN
afl-input/PDFBOX-1048-1.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1065-0.pdf
Normal file
BIN
afl-input/PDFBOX-1065-0.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1065-1.pdf
Normal file
BIN
afl-input/PDFBOX-1065-1.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1067-1.pdf
Normal file
BIN
afl-input/PDFBOX-1067-1.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1068-1.pdf
Normal file
BIN
afl-input/PDFBOX-1068-1.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1074-1.pdf
Normal file
BIN
afl-input/PDFBOX-1074-1.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1074-3.pdf
Normal file
BIN
afl-input/PDFBOX-1074-3.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1094-10.pdf
Normal file
BIN
afl-input/PDFBOX-1094-10.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1094-13.pdf
Normal file
BIN
afl-input/PDFBOX-1094-13.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1094-15.pdf
Normal file
BIN
afl-input/PDFBOX-1094-15.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1094-3.pdf
Normal file
BIN
afl-input/PDFBOX-1094-3.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1094-33.pdf
Normal file
BIN
afl-input/PDFBOX-1094-33.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1094-4.pdf
Normal file
BIN
afl-input/PDFBOX-1094-4.pdf
Normal file
Binary file not shown.
BIN
afl-input/PDFBOX-1095-2.pdf
Normal file
BIN
afl-input/PDFBOX-1095-2.pdf
Normal file
Binary file not shown.
1466
afl-pdf.dict
Normal file
1466
afl-pdf.dict
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
.TH pdfio 3 "pdf read/write library" "2021-10-25" "pdf read/write library"
|
||||
.TH pdfio 3 "pdf read/write library" "2021-11-30" "pdf read/write library"
|
||||
.SH NAME
|
||||
pdfio \- pdf read/write library
|
||||
.SH Introduction
|
||||
|
@ -1,13 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<title>PDFio Programming Manual v1.0.0</title>
|
||||
<title>PDFio Programming Manual v1.0rc1</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||
<meta name="generator" content="codedoc v3.7">
|
||||
<meta name="author" content="Michael R Sweet">
|
||||
<meta name="language" content="en-US">
|
||||
<meta name="copyright" content="Copyright © 2021 by Michael R Sweet">
|
||||
<meta name="version" content="1.0.0">
|
||||
<meta name="version" content="1.0rc1">
|
||||
<style type="text/css"><!--
|
||||
body {
|
||||
background: white;
|
||||
@ -245,7 +245,7 @@ span.string {
|
||||
<body>
|
||||
<div class="header">
|
||||
<p><img class="title" src="pdfio-512.png"></p>
|
||||
<h1 class="title">PDFio Programming Manual v1.0.0</h1>
|
||||
<h1 class="title">PDFio Programming Manual v1.0rc1</h1>
|
||||
<p>Michael R Sweet</p>
|
||||
<p>Copyright © 2021 by Michael R Sweet</p>
|
||||
</div>
|
||||
|
@ -575,7 +575,8 @@ _pdfioArrayGetValue(pdfio_array_t *a, // I - Array
|
||||
pdfio_array_t * // O - New array
|
||||
_pdfioArrayRead(pdfio_file_t *pdf, // I - PDF file
|
||||
pdfio_obj_t *obj, // I - Object, if any
|
||||
_pdfio_token_t *tb) // I - Token buffer/stack
|
||||
_pdfio_token_t *tb, // I - Token buffer/stack
|
||||
size_t depth) // I - Depth of array
|
||||
{
|
||||
pdfio_array_t *array; // New array
|
||||
char token[8192]; // Token from file
|
||||
@ -599,7 +600,7 @@ _pdfioArrayRead(pdfio_file_t *pdf, // I - PDF file
|
||||
|
||||
// Push the token and decode the value...
|
||||
_pdfioTokenPush(tb, token);
|
||||
if (!_pdfioValueRead(pdf, obj, tb, &value))
|
||||
if (!_pdfioValueRead(pdf, obj, tb, &value, depth))
|
||||
break;
|
||||
|
||||
// PDFIO_DEBUG("_pdfioArrayRead(%p): Appending ", (void *)array);
|
||||
|
@ -473,7 +473,8 @@ _pdfioDictGetValue(pdfio_dict_t *dict, // I - Dictionary
|
||||
pdfio_dict_t * // O - New dictionary
|
||||
_pdfioDictRead(pdfio_file_t *pdf, // I - PDF file
|
||||
pdfio_obj_t *obj, // I - Object, if any
|
||||
_pdfio_token_t *tb) // I - Token buffer/stack
|
||||
_pdfio_token_t *tb, // I - Token buffer/stack
|
||||
size_t depth) // I - Depth of dictionary
|
||||
{
|
||||
pdfio_dict_t *dict; // New dictionary
|
||||
char key[256]; // Dictionary key
|
||||
@ -501,7 +502,7 @@ _pdfioDictRead(pdfio_file_t *pdf, // I - PDF file
|
||||
}
|
||||
|
||||
// Then get the next value...
|
||||
if (!_pdfioValueRead(pdf, obj, tb, &value))
|
||||
if (!_pdfioValueRead(pdf, obj, tb, &value, depth))
|
||||
{
|
||||
_pdfioFileError(pdf, "Missing value for dictionary key.");
|
||||
break;
|
||||
|
23
pdfio-file.c
23
pdfio-file.c
@ -25,7 +25,7 @@ static pdfio_obj_t *add_obj(pdfio_file_t *pdf, size_t number, unsigned short gen
|
||||
static int compare_objmaps(_pdfio_objmap_t *a, _pdfio_objmap_t *b);
|
||||
static int compare_objs(pdfio_obj_t **a, pdfio_obj_t **b);
|
||||
static bool load_obj_stream(pdfio_obj_t *obj);
|
||||
static bool load_pages(pdfio_file_t *pdf, pdfio_obj_t *obj);
|
||||
static bool load_pages(pdfio_file_t *pdf, pdfio_obj_t *obj, size_t depth);
|
||||
static bool load_xref(pdfio_file_t *pdf, off_t xref_offset, pdfio_password_cb_t password_cb, void *password_data);
|
||||
static bool write_catalog(pdfio_file_t *pdf);
|
||||
static bool write_pages(pdfio_file_t *pdf);
|
||||
@ -1312,7 +1312,7 @@ load_obj_stream(pdfio_obj_t *obj) // I - Object to load
|
||||
// Read the objects themselves...
|
||||
for (cur_obj = 0; cur_obj < num_objs; cur_obj ++)
|
||||
{
|
||||
if (!_pdfioValueRead(obj->pdf, obj, &tb, &(objs[cur_obj]->value)))
|
||||
if (!_pdfioValueRead(obj->pdf, obj, &tb, &(objs[cur_obj]->value), 0))
|
||||
{
|
||||
pdfioStreamClose(st);
|
||||
return (false);
|
||||
@ -1332,7 +1332,8 @@ load_obj_stream(pdfio_obj_t *obj) // I - Object to load
|
||||
|
||||
static bool // O - `true` on success, `false` on error
|
||||
load_pages(pdfio_file_t *pdf, // I - PDF file
|
||||
pdfio_obj_t *obj) // I - Page object
|
||||
pdfio_obj_t *obj, // I - Page object
|
||||
size_t depth) // I - Depth of page tree
|
||||
{
|
||||
pdfio_dict_t *dict; // Page object dictionary
|
||||
const char *type; // Node type
|
||||
@ -1364,9 +1365,15 @@ load_pages(pdfio_file_t *pdf, // I - PDF file
|
||||
size_t i, // Looping var
|
||||
num_kids; // Number of elements in array
|
||||
|
||||
if (depth >= PDFIO_MAX_DEPTH)
|
||||
{
|
||||
_pdfioFileError(pdf, "Depth of pages objects too great to load.");
|
||||
return (false);
|
||||
}
|
||||
|
||||
for (i = 0, num_kids = pdfioArrayGetSize(kids); i < num_kids; i ++)
|
||||
{
|
||||
if (!load_pages(pdf, pdfioArrayGetObj(kids, i)))
|
||||
if (!load_pages(pdf, pdfioArrayGetObj(kids, i), depth + 1))
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
@ -1496,7 +1503,7 @@ load_xref(
|
||||
|
||||
_pdfioTokenInit(&tb, pdf, (_pdfio_tconsume_cb_t)_pdfioFileConsume, (_pdfio_tpeek_cb_t)_pdfioFilePeek, pdf);
|
||||
|
||||
if (!_pdfioValueRead(pdf, obj, &tb, &trailer))
|
||||
if (!_pdfioValueRead(pdf, obj, &tb, &trailer, 0))
|
||||
{
|
||||
_pdfioFileError(pdf, "Unable to read cross-reference stream dictionary.");
|
||||
return (false);
|
||||
@ -1537,7 +1544,7 @@ load_xref(
|
||||
w_2 = w[0];
|
||||
w_3 = w[0] + w[1];
|
||||
|
||||
if (w[1] == 0 || w[2] > 2 || w_total > sizeof(buffer))
|
||||
if (w[1] == 0 || w[2] > 2 || w[0] > sizeof(buffer) || w[1] > sizeof(buffer) || w[2] > sizeof(buffer) || w_total > sizeof(buffer))
|
||||
{
|
||||
_pdfioFileError(pdf, "Cross-reference stream has invalid W key.");
|
||||
return (false);
|
||||
@ -1751,7 +1758,7 @@ load_xref(
|
||||
|
||||
_pdfioTokenInit(&tb, pdf, (_pdfio_tconsume_cb_t)_pdfioFileConsume, (_pdfio_tpeek_cb_t)_pdfioFilePeek, pdf);
|
||||
|
||||
if (!_pdfioValueRead(pdf, NULL, &tb, &trailer))
|
||||
if (!_pdfioValueRead(pdf, NULL, &tb, &trailer, 0))
|
||||
{
|
||||
_pdfioFileError(pdf, "Unable to read trailer dictionary.");
|
||||
return (false);
|
||||
@ -1803,7 +1810,7 @@ load_xref(
|
||||
|
||||
PDFIO_DEBUG("load_xref: Root=%p(%lu)\n", pdf->root_obj, (unsigned long)pdf->root_obj->number);
|
||||
|
||||
return (load_pages(pdf, pdfioDictGetObj(pdfioObjGetDict(pdf->root_obj), "Pages")));
|
||||
return (load_pages(pdf, pdfioDictGetObj(pdfioObjGetDict(pdf->root_obj), "Pages"), 0));
|
||||
}
|
||||
|
||||
|
||||
|
@ -412,7 +412,7 @@ _pdfioObjLoad(pdfio_obj_t *obj) // I - Object
|
||||
// Then grab the object value...
|
||||
_pdfioTokenInit(&tb, obj->pdf, (_pdfio_tconsume_cb_t)_pdfioFileConsume, (_pdfio_tpeek_cb_t)_pdfioFilePeek, obj->pdf);
|
||||
|
||||
if (!_pdfioValueRead(obj->pdf, obj, &tb, &obj->value))
|
||||
if (!_pdfioValueRead(obj->pdf, obj, &tb, &obj->value, 0))
|
||||
{
|
||||
_pdfioFileError(obj->pdf, "Unable to read value for object %lu.", (unsigned long)obj->number);
|
||||
return (false);
|
||||
|
@ -116,6 +116,8 @@
|
||||
// Types and constants...
|
||||
//
|
||||
|
||||
# define PDFIO_MAX_DEPTH 32 // Maximum nesting depth for values
|
||||
|
||||
typedef enum _pdfio_mode_e // Read/write mode
|
||||
{
|
||||
_PDFIO_MODE_READ, // Read a PDF file
|
||||
@ -341,7 +343,7 @@ struct _pdfio_stream_s // Stream
|
||||
extern void _pdfioArrayDebug(pdfio_array_t *a, FILE *fp) _PDFIO_INTERNAL;
|
||||
extern void _pdfioArrayDelete(pdfio_array_t *a) _PDFIO_INTERNAL;
|
||||
extern _pdfio_value_t *_pdfioArrayGetValue(pdfio_array_t *a, size_t n) _PDFIO_INTERNAL;
|
||||
extern pdfio_array_t *_pdfioArrayRead(pdfio_file_t *pdf, pdfio_obj_t *obj, _pdfio_token_t *ts) _PDFIO_INTERNAL;
|
||||
extern pdfio_array_t *_pdfioArrayRead(pdfio_file_t *pdf, pdfio_obj_t *obj, _pdfio_token_t *ts, size_t depth) _PDFIO_INTERNAL;
|
||||
extern bool _pdfioArrayWrite(pdfio_array_t *a, pdfio_obj_t *obj) _PDFIO_INTERNAL;
|
||||
|
||||
extern void _pdfioCryptoAESInit(_pdfio_aes_t *ctx, const uint8_t *key, size_t keylen, const uint8_t *iv) _PDFIO_INTERNAL;
|
||||
@ -365,7 +367,7 @@ extern void _pdfioDictClear(pdfio_dict_t *dict, const char *key) _PDFIO_INTERNA
|
||||
extern void _pdfioDictDebug(pdfio_dict_t *dict, FILE *fp) _PDFIO_INTERNAL;
|
||||
extern void _pdfioDictDelete(pdfio_dict_t *dict) _PDFIO_INTERNAL;
|
||||
extern _pdfio_value_t *_pdfioDictGetValue(pdfio_dict_t *dict, const char *key) _PDFIO_INTERNAL;
|
||||
extern pdfio_dict_t *_pdfioDictRead(pdfio_file_t *pdf, pdfio_obj_t *obj, _pdfio_token_t *ts) _PDFIO_INTERNAL;
|
||||
extern pdfio_dict_t *_pdfioDictRead(pdfio_file_t *pdf, pdfio_obj_t *obj, _pdfio_token_t *ts, size_t depth) _PDFIO_INTERNAL;
|
||||
extern bool _pdfioDictSetValue(pdfio_dict_t *dict, const char *key, _pdfio_value_t *value) _PDFIO_INTERNAL;
|
||||
extern bool _pdfioDictWrite(pdfio_dict_t *dict, pdfio_obj_t *obj, off_t *length) _PDFIO_INTERNAL;
|
||||
|
||||
@ -405,7 +407,7 @@ extern bool _pdfioTokenRead(_pdfio_token_t *tb, char *buffer, size_t bufsize);
|
||||
extern _pdfio_value_t *_pdfioValueCopy(pdfio_file_t *pdfdst, _pdfio_value_t *vdst, pdfio_file_t *pdfsrc, _pdfio_value_t *vsrc) _PDFIO_INTERNAL;
|
||||
extern void _pdfioValueDebug(_pdfio_value_t *v, FILE *fp) _PDFIO_INTERNAL;
|
||||
extern void _pdfioValueDelete(_pdfio_value_t *v) _PDFIO_INTERNAL;
|
||||
extern _pdfio_value_t *_pdfioValueRead(pdfio_file_t *pdf, pdfio_obj_t *obj, _pdfio_token_t *ts, _pdfio_value_t *v) _PDFIO_INTERNAL;
|
||||
extern _pdfio_value_t *_pdfioValueRead(pdfio_file_t *pdf, pdfio_obj_t *obj, _pdfio_token_t *ts, _pdfio_value_t *v, size_t depth) _PDFIO_INTERNAL;
|
||||
extern bool _pdfioValueWrite(pdfio_file_t *pdf, pdfio_obj_t *obj, _pdfio_value_t *v, off_t *length) _PDFIO_INTERNAL;
|
||||
|
||||
#endif // !PDFIO_PRIVATE_H
|
||||
|
@ -196,7 +196,8 @@ _pdfio_value_t * // O - Value or `NULL` on error/EOF
|
||||
_pdfioValueRead(pdfio_file_t *pdf, // I - PDF file
|
||||
pdfio_obj_t *obj, // I - Object, if any
|
||||
_pdfio_token_t *tb, // I - Token buffer/stack
|
||||
_pdfio_value_t *v) // I - Value
|
||||
_pdfio_value_t *v, // I - Value
|
||||
size_t depth) // I - Depth of value
|
||||
{
|
||||
char token[32768]; // Token buffer
|
||||
#ifdef DEBUG
|
||||
@ -226,15 +227,27 @@ _pdfioValueRead(pdfio_file_t *pdf, // I - PDF file
|
||||
if (!strcmp(token, "["))
|
||||
{
|
||||
// Start of array
|
||||
if (depth >= PDFIO_MAX_DEPTH)
|
||||
{
|
||||
_pdfioFileError(pdf, "Too many nested arrays.");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
v->type = PDFIO_VALTYPE_ARRAY;
|
||||
if ((v->value.array = _pdfioArrayRead(pdf, obj, tb)) == NULL)
|
||||
if ((v->value.array = _pdfioArrayRead(pdf, obj, tb, depth + 1)) == NULL)
|
||||
return (NULL);
|
||||
}
|
||||
else if (!strcmp(token, "<<"))
|
||||
{
|
||||
// Start of dictionary
|
||||
if (depth >= PDFIO_MAX_DEPTH)
|
||||
{
|
||||
_pdfioFileError(pdf, "Too many nested dictionaries.");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
v->type = PDFIO_VALTYPE_DICT;
|
||||
if ((v->value.dict = _pdfioDictRead(pdf, obj, tb)) == NULL)
|
||||
if ((v->value.dict = _pdfioDictRead(pdf, obj, tb, depth + 1)) == NULL)
|
||||
return (NULL);
|
||||
}
|
||||
else if (!strncmp(token, "(D:", 3))
|
||||
|
@ -2,5 +2,5 @@ Name: pdfio
|
||||
Description: PDF read/write library
|
||||
URL: https://www.msweet.org/pdfio
|
||||
Requires: zlib >= 1.0
|
||||
Libs: -L${prefix}/lib -lpdfio
|
||||
Libs: -L${prefix}/lib -lpdfio -lm
|
||||
Cflags: -I${prefix}/include
|
||||
|
@ -87,7 +87,7 @@
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>PDFIO_VERSION="1.0b2";WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>PDFIO_VERSION="1.0rc1";WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@ -101,7 +101,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>PDFIO_VERSION="1.0b2";WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>PDFIO_VERSION="1.0rc1";WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@ -115,7 +115,7 @@
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>PDFIO_VERSION="1.0b2";_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>PDFIO_VERSION="1.0rc1";_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@ -130,7 +130,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>PDFIO_VERSION="1.0b2";NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>PDFIO_VERSION="1.0rc1";NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<metadata>
|
||||
<id>pdfio_native</id>
|
||||
<title>PDFio Library for VS2019+</title>
|
||||
<version>1.0.0-b7</version>
|
||||
<version>1.0.0-rc1</version>
|
||||
<authors>Michael R Sweet</authors>
|
||||
<owners>michaelrsweet</owners>
|
||||
<projectUrl>https://github.com/michaelrsweet/pappl</projectUrl>
|
||||
@ -16,7 +16,7 @@
|
||||
<copyright>Copyright © 2019-2021 by Michael R Sweet</copyright>
|
||||
<tags>pdf file native</tags>
|
||||
<dependencies>
|
||||
<dependency id="pdfio_native.redist" version="1.0.0-b7" />
|
||||
<dependency id="pdfio_native.redist" version="1.0.0-rc1" />
|
||||
<dependency id="zlib_native.redist" version="1.2.11" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<metadata>
|
||||
<id>pdfio_native.redist</id>
|
||||
<title>PDFio Library for VS2019+</title>
|
||||
<version>1.0.0-b7</version>
|
||||
<version>1.0.0-rc1</version>
|
||||
<authors>Michael R Sweet</authors>
|
||||
<owners>michaelrsweet</owners>
|
||||
<projectUrl>https://github.com/michaelrsweet/pappl</projectUrl>
|
||||
|
@ -971,7 +971,7 @@ do_unit_tests(void)
|
||||
fputs("_pdfioValueRead(complex_dict): ", stdout);
|
||||
s = complex_dict;
|
||||
_pdfioTokenInit(&tb, inpdf, (_pdfio_tconsume_cb_t)token_consume_cb, (_pdfio_tpeek_cb_t)token_peek_cb, (void *)&s);
|
||||
if (_pdfioValueRead(inpdf, NULL, &tb, &value))
|
||||
if (_pdfioValueRead(inpdf, NULL, &tb, &value, 0))
|
||||
{
|
||||
// TODO: Check value...
|
||||
fputs("PASS: ", stdout);
|
||||
@ -985,7 +985,7 @@ do_unit_tests(void)
|
||||
fputs("_pdfioValueRead(cid_dict): ", stdout);
|
||||
s = cid_dict;
|
||||
_pdfioTokenInit(&tb, inpdf, (_pdfio_tconsume_cb_t)token_consume_cb, (_pdfio_tpeek_cb_t)token_peek_cb, (void *)&s);
|
||||
if (_pdfioValueRead(inpdf, NULL, &tb, &value))
|
||||
if (_pdfioValueRead(inpdf, NULL, &tb, &value, 0))
|
||||
{
|
||||
// TODO: Check value...
|
||||
fputs("PASS: ", stdout);
|
||||
|
Reference in New Issue
Block a user