From 431c7db3b7ea3e2db9cc7066cb5334e4bb7dcb75 Mon Sep 17 00:00:00 2001
From: "Sven M. Hallberg" <pesco@khjk.org>
Date: Thu, 30 Mar 2023 13:27:46 +0000
Subject: [PATCH] remove useless/erroneous condition

The offset can never be negative (size_t is unsigned).
And this treated offset = 0 as out of bounds, which is nonsense.
In fact, offset == size is also not invalid (it is the end of file).
---
 pdf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pdf.c b/pdf.c
index 112a0d5..0fb055a 100644
--- a/pdf.c
+++ b/pdf.c
@@ -4978,7 +4978,7 @@ parse_xrefs(const uint8_t *input, size_t sz, size_t *nxrefs)
 
 	// verify the offset recovered is bounded to be in the file
 	// XXX this check is already present below by virtue of h_seek()
-	if ( (offset <=0) || (offset >= sz) ) {
+	if (offset > sz) {
 		log_message(5, "VIOLATION[5]: Invalid xref table offset = %ld. Valid range <0, %ld>\n",
 				offset, sz);
 		goto end;
-- 
GitLab