[poppler] poppler/XRef.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Fri Dec 26 13:56:47 PST 2008


 poppler/XRef.cc |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit f41fa9ee71aef5539cf9976c79b32bf1713c8167
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Dec 26 22:56:12 2008 +0100

    Change the overflow check to the same used in gmem.cc, much more easy to understand

diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index 0e99a3f..832a038 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -129,7 +129,7 @@ ObjectStream::ObjectStream(XRef *xref, int objStrNumA) {
     goto err1;
   }
 
-  if (nObjects*(int)sizeof(int)/sizeof(int) != nObjects) {
+  if (nObjects >= INT_MAX / (int)sizeof(int)) {
     error(-1, "Invalid 'nObjects'");
     goto err1;
   }
@@ -421,7 +421,7 @@ GBool XRef::readXRefTable(Parser *parser, Guint *pos) {
       if (newSize < 0) {
 	goto err1;
       }
-      if (newSize*(int)sizeof(XRefEntry)/sizeof(XRefEntry) != newSize) {
+      if (newSize >= INT_MAX / (int)sizeof(XRefEntry)) {
         error(-1, "Invalid 'obj' parameters'");
         goto err1;
       }
@@ -537,7 +537,7 @@ GBool XRef::readXRefStream(Stream *xrefStr, Guint *pos) {
     goto err1;
   }
   if (newSize > size) {
-    if (newSize * (int)sizeof(XRefEntry)/sizeof(XRefEntry) != newSize) {
+    if (newSize >= INT_MAX / (int)sizeof(XRefEntry)) {
       error(-1, "Invalid 'size' parameter.");
       return gFalse;
     }
@@ -634,7 +634,7 @@ GBool XRef::readXRefStreamSection(Stream *xrefStr, int *w, int first, int n) {
     if (newSize < 0) {
       return gFalse;
     }
-    if (newSize*(int)sizeof(XRefEntry)/sizeof(XRefEntry) != newSize) {
+    if (newSize >= INT_MAX / (int)sizeof(XRefEntry)) {
       error(-1, "Invalid 'size' inside xref table.");
       return gFalse;
     }
@@ -780,7 +780,7 @@ GBool XRef::constructXRef() {
 		    error(-1, "Bad object number");
 		    return gFalse;
 		  }
-		  if (newSize*(int)sizeof(XRefEntry)/sizeof(XRefEntry) != newSize) {
+		  if (newSize >= INT_MAX / (int)sizeof(XRefEntry)) {
 		    error(-1, "Invalid 'obj' parameters.");
 		    return gFalse;
 		  }
@@ -809,7 +809,7 @@ GBool XRef::constructXRef() {
     } else if (!strncmp(p, "endstream", 9)) {
       if (streamEndsLen == streamEndsSize) {
 	streamEndsSize += 64;
-        if (streamEndsSize*(int)sizeof(int)/sizeof(int) != streamEndsSize) {
+        if (streamEndsSize >= INT_MAX / (int)sizeof(int)) {
           error(-1, "Invalid 'endstream' parameter.");
           return gFalse;
         }


More information about the poppler mailing list