diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-08-04 01:21:15 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-08-04 01:21:15 +0000 |
commit | f81ecad624db4959d5ed4f1320b2d4a5762a2a42 (patch) | |
tree | ab96ac4c2848ce42b20015fbaedfab9610c07e83 | |
parent | 60a28d74bbe154d85c0b0202a6330fff510dcb02 (diff) | |
download | libextractor-f81ecad624db4959d5ed4f1320b2d4a5762a2a42.tar.gz libextractor-f81ecad624db4959d5ed4f1320b2d4a5762a2a42.zip |
fixes
-rw-r--r-- | src/main/TODO | 3 | ||||
-rw-r--r-- | src/main/extractor_datasource.c | 14 | ||||
-rw-r--r-- | src/main/test_extractor.c | 3 | ||||
-rw-r--r-- | src/main/test_gzip.c | 6 |
4 files changed, 21 insertions, 5 deletions
diff --git a/src/main/TODO b/src/main/TODO index f3d3e05..19f7787 100644 --- a/src/main/TODO +++ b/src/main/TODO | |||
@@ -4,3 +4,6 @@ | |||
4 | 4 | ||
5 | * MAX_META_DATA buffer of 32 MB is a bit big as a non-growing default size; | 5 | * MAX_META_DATA buffer of 32 MB is a bit big as a non-growing default size; |
6 | also, valgrind reports it is leaked even though printf-debugging shows it is not (!?) | 6 | also, valgrind reports it is leaked even though printf-debugging shows it is not (!?) |
7 | |||
8 | * for some reason, if a plugin crashes or something goes wrong (i.e. with a seek), | ||
9 | the whole system hangs (not good...) | ||
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; |
diff --git a/src/main/test_extractor.c b/src/main/test_extractor.c index ca3b737..84588fd 100644 --- a/src/main/test_extractor.c +++ b/src/main/test_extractor.c | |||
@@ -61,7 +61,8 @@ EXTRACTOR_test_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
61 | fprintf (stderr, "Unexpected data at offset 0\n"); | 61 | fprintf (stderr, "Unexpected data at offset 0\n"); |
62 | abort (); | 62 | abort (); |
63 | } | 63 | } |
64 | if (1024 * 150 != ec->get_size (ec->cls)) | 64 | if ( (1024 * 150 != ec->get_size (ec->cls)) && |
65 | (UINT64_MAX != ec->get_size (ec->cls)) ) | ||
65 | { | 66 | { |
66 | fprintf (stderr, "Unexpected file size returned (expected 150k)\n"); | 67 | fprintf (stderr, "Unexpected file size returned (expected 150k)\n"); |
67 | abort (); | 68 | abort (); |
diff --git a/src/main/test_gzip.c b/src/main/test_gzip.c index 2eb577b..1da58b1 100644 --- a/src/main/test_gzip.c +++ b/src/main/test_gzip.c | |||
@@ -63,10 +63,14 @@ process_replies (void *cls, | |||
63 | ret = 3; | 63 | ret = 3; |
64 | return 1; | 64 | return 1; |
65 | } | 65 | } |
66 | if (0 == strcmp (plugin_name, | ||
67 | "<zlib>")) | ||
68 | return 0; /* skip this one */ | ||
66 | if (0 != strcmp (plugin_name, | 69 | if (0 != strcmp (plugin_name, |
67 | "test")) | 70 | "test")) |
68 | { | 71 | { |
69 | fprintf (stderr, "plugin name invalid\n"); | 72 | fprintf (stderr, "plugin name invalid: `%s'\n", |
73 | plugin_name); | ||
70 | ret = 4; | 74 | ret = 4; |
71 | return 1; | 75 | return 1; |
72 | } | 76 | } |