From 97931e1470880f644ec6efefcce8f2bab33f8b30 Mon Sep 17 00:00:00 2001 From: yzrh Date: Thu, 29 Dec 2022 05:23:04 +0000 Subject: Fix PDF object check. Signed-off-by: yzrh --- CHANGE.md | 3 ++- src/cnki_pdf.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGE.md b/CHANGE.md index a832777..63a76c3 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,10 +1,11 @@ 0.3.0 (2023-XX-XX) ================== -* Handle missing but referenced root object. * Support JPEG 2000 for HN. * Support HN figure placement. * Support HN text overlay. +* Handle missing but referenced root object. +* Fix buffer overflow. 0.2.1 (2022-12-26) ================== diff --git a/src/cnki_pdf.c b/src/cnki_pdf.c index 502a0ce..328a989 100644 --- a/src/cnki_pdf.c +++ b/src/cnki_pdf.c @@ -322,12 +322,13 @@ cnki_pdf(cnki_t **param) root = i; } - if ((*param)->stat > 0) - printf("Root object is %d.\n", - root); + if (root == 0) + root = pdf_get_free_id(&pdf); + else if ((*param)->stat > 0) + printf("Root object is %d.\n", root); } - if (pdf_get_kid_count(&pdf, root) == 0) { + if (pdf_get_obj(&pdf, root, NULL) != 0) { if ((*param)->stat > 0) printf("Root object is missing\n"); -- cgit v1.2.3