aboutsummaryrefslogtreecommitdiffstats
path: root/g10/compress-bz2.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2009-09-03 11:29:25 +0000
committerWerner Koch <[email protected]>2009-09-03 11:29:25 +0000
commit34db1110fce318eb150a85cf843f01089c30edcc (patch)
treeddef434be84105fce831bee17d5772b3b5365265 /g10/compress-bz2.c
parentFix for extended length Le in decipher (diff)
downloadgnupg-34db1110fce318eb150a85cf843f01089c30edcc.tar.gz
gnupg-34db1110fce318eb150a85cf843f01089c30edcc.zip
Fix bug#1011.
Diffstat (limited to 'g10/compress-bz2.c')
-rw-r--r--g10/compress-bz2.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/g10/compress-bz2.c b/g10/compress-bz2.c
index 3c1c649b5..1dabca14e 100644
--- a/g10/compress-bz2.c
+++ b/g10/compress-bz2.c
@@ -118,6 +118,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",
@@ -132,12 +133,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",
@@ -151,6 +156,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 = GPG_ERR_BAD_DATA;
+ break;
+ }
}
while( bzs->avail_out && zrc != BZ_STREAM_END && zrc != BZ_PARAM_ERROR );