aboutsummaryrefslogtreecommitdiff
path: root/src/main/extractor_datasource.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/extractor_datasource.c')
-rw-r--r--src/main/extractor_datasource.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/extractor_datasource.c b/src/main/extractor_datasource.c
index e2f151a..1c19c98 100644
--- a/src/main/extractor_datasource.c
+++ b/src/main/extractor_datasource.c
@@ -326,7 +326,10 @@ bfds_seek (struct BufferedFileDataSource *bfds,
326 } 326 }
327 if (bfds->fpos + bfds->buffer_pos + pos > bfds->fsize) 327 if (bfds->fpos + bfds->buffer_pos + pos > bfds->fsize)
328 { 328 {
329 LOG ("Invalid seek operation\n"); 329 LOG ("Invalid seek operation to %lld from %llu (max is %llu)\n",
330 (long long) pos,
331 bfds->fpos + bfds->buffer_pos,
332 (unsigned long long) bfds->fsize);
330 return -1; 333 return -1;
331 } 334 }
332 if ( (NULL == bfds->buffer) || 335 if ( (NULL == bfds->buffer) ||
@@ -537,11 +540,16 @@ cfs_init_decompressor_zlib (struct CompressedFileSource *cfs,
537 unsigned int gzip_header_length = 10; 540 unsigned int gzip_header_length = 10;
538 unsigned char hdata[12]; 541 unsigned char hdata[12];
539 542
543 if (0 != bfds_seek (cfs->bfds, 0, SEEK_SET))
544 {
545 LOG ("Failed to seek to offset 0!\n");
546 return -1;
547 }
540 /* Process gzip header */ 548 /* Process gzip header */
541 if (sizeof (hdata) > bfds_read (cfs->bfds, hdata, sizeof (hdata))) 549 if (sizeof (hdata) > bfds_read (cfs->bfds, hdata, sizeof (hdata)))
542 return -1; 550 return -1;
543 if (0 != (hdata[3] & 0x4)) /* FEXTRA set */ 551 if (0 != (hdata[3] & 0x4)) /* FEXTRA set */
544 gzip_header_length += 2 + (hdata[10] & 0xff) + ((hdata[11] & 0xff) * 256); 552 gzip_header_length += 2 + (hdata[10] & 0xff) + ((hdata[11] & 0xff) * 256);
545 553
546 if (0 != (hdata[3] & 0x8)) 554 if (0 != (hdata[3] & 0x8))
547 { 555 {
@@ -819,7 +827,7 @@ cfs_read_zlib (struct CompressedFileSource *cfs,
819 if ( (Z_OK != ret) && (Z_STREAM_END != ret) ) 827 if ( (Z_OK != ret) && (Z_STREAM_END != ret) )
820 return -1; /* unexpected error */ 828 return -1; /* unexpected error */
821 /* go backwards by the number of bytes left in the buffer */ 829 /* go backwards by the number of bytes left in the buffer */
822 if (-1 == bfds_seek (cfs->bfds, - cfs->strm.avail_in, SEEK_CUR)) 830 if (-1 == bfds_seek (cfs->bfds, - (int64_t) cfs->strm.avail_in, SEEK_CUR))
823 return -1; 831 return -1;
824 /* copy decompressed bytes to target buffer */ 832 /* copy decompressed bytes to target buffer */
825 in = cfs->strm.total_out; 833 in = cfs->strm.total_out;