76f8c5
From b54e1fc3e0d2600621a28d50f9f085b9e38619c2 Mon Sep 17 00:00:00 2001
76f8c5
From: Adam Reichold <adam.reichold@t-online.de>
76f8c5
Date: Fri, 1 Feb 2019 08:42:27 +0100
76f8c5
Subject: [PATCH] Also defend against requests for negative XRef indices.
76f8c5
 oss-fuzz/12797
76f8c5
76f8c5
---
76f8c5
 poppler/XRef.cc | 5 +++++
76f8c5
 1 file changed, 5 insertions(+)
76f8c5
76f8c5
diff --git a/poppler/XRef.cc b/poppler/XRef.cc
76f8c5
index d042d1f4..ac2cd0ce 100644
76f8c5
--- a/poppler/XRef.cc
76f8c5
+++ b/poppler/XRef.cc
76f8c5
@@ -1565,6 +1565,11 @@ DummyXRefEntry dummyXRefEntry;
76f8c5
 
76f8c5
 XRefEntry *XRef::getEntry(int i, GBool complainIfMissing)
76f8c5
 {
76f8c5
+  if (unlikely(i < 0)) {
76f8c5
+    error(errInternal, -1, "Request for invalid XRef entry [{0:d}]", i);
76f8c5
+    return &dummyXRefEntry;
76f8c5
+  }
76f8c5
+
76f8c5
   if (i >= size || entries[i].type == xrefEntryNone) {
76f8c5
 
76f8c5
     if ((!xRefStream) && mainXRefEntriesOffset) {
76f8c5
-- 
76f8c5
2.20.1
76f8c5