gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r23091 - Extractor/src/main


From: gnunet
Subject: [GNUnet-SVN] r23091 - Extractor/src/main
Date: Sat, 4 Aug 2012 03:08:35 +0200

Author: grothoff
Date: 2012-08-04 03:08:35 +0200 (Sat, 04 Aug 2012)
New Revision: 23091

Modified:
   Extractor/src/main/extractor_datasource.c
Log:
update

Modified: Extractor/src/main/extractor_datasource.c
===================================================================
--- Extractor/src/main/extractor_datasource.c   2012-08-04 01:02:26 UTC (rev 
23090)
+++ Extractor/src/main/extractor_datasource.c   2012-08-04 01:08:35 UTC (rev 
23091)
@@ -364,7 +364,10 @@
        }
       if (pos > bfds->fsize)
        {
-         LOG ("Invalid seek operation\n");
+         LOG ("Invalid seek operation (%lld > %llu) %d\n",
+              (long long) pos,
+              (unsigned long long) bfds->fsize,
+              SEEK_SET == whence);
          return -1;
        }
       if ( (NULL == bfds->buffer) ||
@@ -538,8 +541,7 @@
   if (sizeof (hdata) > bfds_read (cfs->bfds, hdata, sizeof (hdata)))
     return -1;
   if (0 != (hdata[3] & 0x4)) /* FEXTRA  set */
-    gzip_header_length += 2 + (unsigned) (hdata[10] & 0xff) +
-      (((unsigned) (hdata[11] & 0xff)) * 256);
+    gzip_header_length += 2 + (hdata[10] & 0xff) + ((hdata[11] & 0xff) * 256);
 
   if (0 != (hdata[3] & 0x8)) 
     {
@@ -550,18 +552,27 @@
       ssize_t buf_bytes;
       
       if (gzip_header_length > bfds_seek (cfs->bfds, gzip_header_length, 
SEEK_SET))
-       return -1;
+       {
+         LOG ("Corrupt gzip, failed to seek to end of header\n");
+         return -1;
+       }
       buf_bytes = bfds_read (cfs->bfds, fname, sizeof (fname));
       if (buf_bytes <= 0)
-       return -1;
+       {
+         LOG ("Corrupt gzip, failed to read filename\n");        
+         return -1;
+       }
       if (NULL == (cptr = memchr (fname, 0, buf_bytes)))
-       return -1;
+       {
+         LOG ("Corrupt gzip, failed to read filename terminator\n");
+         return -1;
+       }
       len = cptr - fname;
       if (0 != proc (proc_cls, "<zlib>", EXTRACTOR_METATYPE_FILENAME,
                     EXTRACTOR_METAFORMAT_C_STRING, "text/plain",
                     fname,
                     len))
-       return 0; /* done */
+       return 0; /* done */    
       gzip_header_length += len + 1;
     }
   
@@ -574,12 +585,21 @@
       size_t len;
       
       if (gzip_header_length > bfds_seek (cfs->bfds, gzip_header_length, 
SEEK_SET))
-       return -1;
+       {
+         LOG ("Corrupt gzip, failed to seek to end of header\n");
+         return -1;
+       }
       buf_bytes = bfds_read (cfs->bfds, fcomment, sizeof (fcomment));
       if (buf_bytes <= 0)
-       return -1;
+       {
+         LOG ("Corrupt gzip, failed to read comment\n");         
+         return -1;
+       }
       if (NULL == (cptr = memchr (fcomment, 0, buf_bytes)))
-       return -1;
+       {
+         LOG ("Corrupt gzip, failed to read comment terminator\n");
+         return -1;
+       }
       len = cptr - fcomment;
       if (0 != proc (proc_cls, "<zlib>", EXTRACTOR_METATYPE_COMMENT,
                     EXTRACTOR_METAFORMAT_C_STRING, "text/plain",




reply via email to

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