gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r2470 - Extractor/src/plugins/pdf


From: grothoff
Subject: [GNUnet-SVN] r2470 - Extractor/src/plugins/pdf
Date: Fri, 10 Mar 2006 15:35:03 -0800 (PST)

Author: grothoff
Date: 2006-03-10 15:35:00 -0800 (Fri, 10 Mar 2006)
New Revision: 2470

Modified:
   Extractor/src/plugins/pdf/Stream.cc
   Extractor/src/plugins/pdf/Stream.h
   Extractor/src/plugins/pdf/gmem.cc
Log:
0.5.10-diff

Modified: Extractor/src/plugins/pdf/Stream.cc
===================================================================
--- Extractor/src/plugins/pdf/Stream.cc 2006-03-10 23:28:56 UTC (rev 2469)
+++ Extractor/src/plugins/pdf/Stream.cc 2006-03-10 23:35:00 UTC (rev 2470)
@@ -16,6 +16,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
+#include <limits.h>
 #ifndef WIN32
 #include <unistd.h>
 #endif
@@ -419,13 +420,14 @@
   nBits = nBitsA;
   predLine = NULL;
   ok = gFalse;
+  nVals = width * nComps;
 
   if (width <= 0 || nComps <= 0 || nBits <= 0 ||
       nComps >= INT_MAX/nBits ||
-      width >= INT_MAX/nComps/nBits) {
+      width >= INT_MAX/nComps/nBits ||
+      nVals * nBits + 7 < 0) {
     return;
   }
-  nVals = width * nComps;
   if (nVals + 7 <= 0) {
     return;
   }
@@ -1291,6 +1293,11 @@
   byteAlign = byteAlignA;
   columns = columnsA;
 
+  if (columns < 1)
+    columns = 1;
+  if (columns + 4 <= 0) 
+    columns = INT_MAX - 4;        
+  
   rows = rowsA;
   endOfBlock = endOfBlockA;
   black = blackA;
@@ -2933,6 +2940,7 @@
   width = read16();
   numComps = str->getChar();
   if (numComps <= 0 || numComps > 4) {
+    numComps = 0;        
     return gFalse;
   }
 
@@ -2963,6 +2971,7 @@
   width = read16();
   numComps = str->getChar();
   if (numComps <= 0 || numComps > 4) {
+    numComps = 0;        
     return gFalse;
   }
   if (prec != 8) {
@@ -3076,6 +3085,7 @@
        numACHuffTables = index+1;
       tbl = &acHuffTables[index];
     } else {
+      index &= 0x0f;       
       if (index >= numDCHuffTables)
        numDCHuffTables = index+1;
       tbl = &dcHuffTables[index];

Modified: Extractor/src/plugins/pdf/Stream.h
===================================================================
--- Extractor/src/plugins/pdf/Stream.h  2006-03-10 23:28:56 UTC (rev 2469)
+++ Extractor/src/plugins/pdf/Stream.h  2006-03-10 23:35:00 UTC (rev 2470)
@@ -534,7 +534,7 @@
   short getWhiteCode();
   short getBlackCode();
   short lookBits(int n);
-  void eatBits(int n) { inputBits -= n; }
+  void eatBits(int n) { if ((inputBits -= n) < 0) inputBits = 0; }
 };
 
 //------------------------------------------------------------------------

Modified: Extractor/src/plugins/pdf/gmem.cc
===================================================================
--- Extractor/src/plugins/pdf/gmem.cc   2006-03-10 23:28:56 UTC (rev 2469)
+++ Extractor/src/plugins/pdf/gmem.cc   2006-03-10 23:35:00 UTC (rev 2470)
@@ -10,6 +10,7 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include <string.h>
+#include <limits.h>
 #include "gmem.h"
 
 #ifdef DEBUG_MEM
@@ -61,7 +62,7 @@
   int lst;
   unsigned long *trl, *p;
 
-  if (size == 0)
+  if (size <= 0)
     return NULL;
   size1 = gMemDataSize(size);
   if (!(mem = (char *)malloc(size1 + gMemHdrSize + gMemTrlSize))) {
@@ -83,7 +84,7 @@
 #else
   void *p;
 
-  if (size == 0)
+  if (size <= 0)
     return NULL;
   if (!(p = malloc(size))) {
     fprintf(stderr, "Out of memory\n");
@@ -99,7 +100,7 @@
   void *q;
   int oldSize;
 
-  if (size == 0) {
+  if (size <= 0) {
     if (p)
       gfree(p);
     return NULL;
@@ -117,7 +118,7 @@
 #else
   void *q;
 
-  if (size == 0) {
+  if (size <= 0) {
     if (p)
       free(p);
     return NULL;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]