From ca4f20e84cbc58f7436357930bead60e85dd7bdc Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 28 Jul 2025 19:11:17 +0100 Subject: [PATCH] Clarify token too large errors (Issue #131) --- CHANGES.md | 1 + pdfio-token.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 81aceaf..5ef8462 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ v1.5.4 - YYYY-MM-DD - Updated indirect reference reading code to limit the range of generation numbers. +- Updated error messages for too large tokens (Issue #131) - Fixed a JPEG copy bug (Issue #132) diff --git a/pdfio-token.c b/pdfio-token.c index 70115c9..dd9cef6 100644 --- a/pdfio-token.c +++ b/pdfio-token.c @@ -380,7 +380,7 @@ _pdfioTokenRead(_pdfio_token_t *tb, // I - Token buffer/stack else { // Out of space - _pdfioFileError(tb->pdf, "Token too large."); + _pdfioFileError(tb->pdf, "String token too large."); *bufptr = '\0'; return (false); } @@ -408,7 +408,7 @@ _pdfioTokenRead(_pdfio_token_t *tb, // I - Token buffer/stack if ((2 * (bytes + 1)) > bufsize) { // Out of space... - _pdfioFileError(tb->pdf, "Token too large."); + _pdfioFileError(tb->pdf, "Binary string token too large."); *bufptr = '\0'; return (false); } @@ -442,7 +442,7 @@ _pdfioTokenRead(_pdfio_token_t *tb, // I - Token buffer/stack else { // Out of space... - _pdfioFileError(tb->pdf, "Token too large."); + _pdfioFileError(tb->pdf, "Keyword token too large."); *bufptr = '\0'; return (false); } @@ -474,7 +474,7 @@ _pdfioTokenRead(_pdfio_token_t *tb, // I - Token buffer/stack else { // Out of space... - _pdfioFileError(tb->pdf, "Token too large."); + _pdfioFileError(tb->pdf, "Number token too large."); *bufptr = '\0'; return (false); } @@ -523,7 +523,7 @@ _pdfioTokenRead(_pdfio_token_t *tb, // I - Token buffer/stack else { // Out of space - _pdfioFileError(tb->pdf, "Token too large."); + _pdfioFileError(tb->pdf, "Name token too large."); *bufptr = '\0'; return (false); } @@ -566,7 +566,7 @@ _pdfioTokenRead(_pdfio_token_t *tb, // I - Token buffer/stack else { // Too large - _pdfioFileError(tb->pdf, "Token too large."); + _pdfioFileError(tb->pdf, "Hex string token too large."); *bufptr = '\0'; return (false); }