commit f81ecad624db4959d5ed4f1320b2d4a5762a2a42
parent 60a28d74bbe154d85c0b0202a6330fff510dcb02
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 4 Aug 2012 01:21:15 +0000
fixes
Diffstat:
4 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/src/main/TODO b/src/main/TODO
@@ -4,3 +4,6 @@
* MAX_META_DATA buffer of 32 MB is a bit big as a non-growing default size;
also, valgrind reports it is leaked even though printf-debugging shows it is not (!?)
+
+* for some reason, if a plugin crashes or something goes wrong (i.e. with a seek),
+ the whole system hangs (not good...)
diff --git a/src/main/extractor_datasource.c b/src/main/extractor_datasource.c
@@ -326,7 +326,10 @@ bfds_seek (struct BufferedFileDataSource *bfds,
}
if (bfds->fpos + bfds->buffer_pos + pos > bfds->fsize)
{
- LOG ("Invalid seek operation\n");
+ LOG ("Invalid seek operation to %lld from %llu (max is %llu)\n",
+ (long long) pos,
+ bfds->fpos + bfds->buffer_pos,
+ (unsigned long long) bfds->fsize);
return -1;
}
if ( (NULL == bfds->buffer) ||
@@ -537,11 +540,16 @@ cfs_init_decompressor_zlib (struct CompressedFileSource *cfs,
unsigned int gzip_header_length = 10;
unsigned char hdata[12];
+ if (0 != bfds_seek (cfs->bfds, 0, SEEK_SET))
+ {
+ LOG ("Failed to seek to offset 0!\n");
+ return -1;
+ }
/* Process gzip header */
if (sizeof (hdata) > bfds_read (cfs->bfds, hdata, sizeof (hdata)))
return -1;
if (0 != (hdata[3] & 0x4)) /* FEXTRA set */
- gzip_header_length += 2 + (hdata[10] & 0xff) + ((hdata[11] & 0xff) * 256);
+ gzip_header_length += 2 + (hdata[10] & 0xff) + ((hdata[11] & 0xff) * 256);
if (0 != (hdata[3] & 0x8))
{
@@ -819,7 +827,7 @@ cfs_read_zlib (struct CompressedFileSource *cfs,
if ( (Z_OK != ret) && (Z_STREAM_END != ret) )
return -1; /* unexpected error */
/* go backwards by the number of bytes left in the buffer */
- if (-1 == bfds_seek (cfs->bfds, - cfs->strm.avail_in, SEEK_CUR))
+ if (-1 == bfds_seek (cfs->bfds, - (int64_t) cfs->strm.avail_in, SEEK_CUR))
return -1;
/* copy decompressed bytes to target buffer */
in = cfs->strm.total_out;
diff --git a/src/main/test_extractor.c b/src/main/test_extractor.c
@@ -61,7 +61,8 @@ EXTRACTOR_test_extract_method (struct EXTRACTOR_ExtractContext *ec)
fprintf (stderr, "Unexpected data at offset 0\n");
abort ();
}
- if (1024 * 150 != ec->get_size (ec->cls))
+ if ( (1024 * 150 != ec->get_size (ec->cls)) &&
+ (UINT64_MAX != ec->get_size (ec->cls)) )
{
fprintf (stderr, "Unexpected file size returned (expected 150k)\n");
abort ();
diff --git a/src/main/test_gzip.c b/src/main/test_gzip.c
@@ -63,10 +63,14 @@ process_replies (void *cls,
ret = 3;
return 1;
}
+ if (0 == strcmp (plugin_name,
+ "<zlib>"))
+ return 0; /* skip this one */
if (0 != strcmp (plugin_name,
"test"))
{
- fprintf (stderr, "plugin name invalid\n");
+ fprintf (stderr, "plugin name invalid: `%s'\n",
+ plugin_name);
ret = 4;
return 1;
}