aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog5
-rw-r--r--g10/compress-bz2.c18
-rw-r--r--g10/compress.c3
3 files changed, 22 insertions, 4 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 8d56724e7..e28361d4a 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,8 @@
+2009-09-02 Werner Koch <[email protected]>
+
+ * compress-bz2.c (do_uncompress): Detect unexpected EOF. Fixes
+ bug#1011.
+
2009-08-26 Werner Koch <[email protected]>
* keyedit.c (menu_revsig): Check for signature right away. Fix
diff --git a/g10/compress-bz2.c b/g10/compress-bz2.c
index 53b65ef3a..baef92f3f 100644
--- a/g10/compress-bz2.c
+++ b/g10/compress-bz2.c
@@ -117,6 +117,7 @@ do_uncompress( compress_filter_context_t *zfx, bz_stream *bzs,
size_t n;
int nread, count;
int refill = !bzs->avail_in;
+ int eofseen = 0;
if( DBG_FILTER )
log_debug("begin bzDecompress: avail_in=%u, avail_out=%u, inbuf=%u\n",
@@ -131,12 +132,16 @@ do_uncompress( compress_filter_context_t *zfx, bz_stream *bzs,
bzs->next_in = zfx->inbuf;
count = zfx->inbufsize - n;
nread = iobuf_read( a, zfx->inbuf + n, count );
- if( nread == -1 ) nread = 0;
+ if( nread == -1 )
+ {
+ eofseen = 1;
+ nread = 0;
+ }
n += nread;
bzs->avail_in = n;
}
-
- refill = 1;
+ if (!eofseen)
+ refill = 1;
if( DBG_FILTER )
log_debug("enter bzDecompress: avail_in=%u, avail_out=%u\n",
@@ -150,6 +155,13 @@ do_uncompress( compress_filter_context_t *zfx, bz_stream *bzs,
rc = -1; /* eof */
else if( zrc != BZ_OK && zrc != BZ_PARAM_ERROR )
log_fatal("bz2lib inflate problem: rc=%d\n", zrc );
+ else if (zrc == BZ_OK && eofseen
+ && !bzs->avail_in && bzs->avail_out > 0)
+ {
+ log_error ("unexpected EOF in bz2lib\n");
+ rc = G10ERR_READ_FILE;
+ break;
+ }
}
while( bzs->avail_out && zrc != BZ_STREAM_END && zrc != BZ_PARAM_ERROR );
diff --git a/g10/compress.c b/g10/compress.c
index fd9a73229..2c1617422 100644
--- a/g10/compress.c
+++ b/g10/compress.c
@@ -175,7 +175,8 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs,
#endif /* __riscos__ */
count = zfx->inbufsize - n;
nread = iobuf_read( a, zfx->inbuf + n, count );
- if( nread == -1 ) nread = 0;
+ if( nread == -1 )
+ nread = 0;
n += nread;
/* If we use the undocumented feature to suppress
* the zlib header, we have to give inflate an