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