mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-05 12:31:50 +01:00
gpg: Emit status lines for errors in the compression layer.
* g10/compress-bz2.c: Replace all log_fatal by log_error, write_status_error, and g10_exit. (do_uncompress): Ditto. -- This gives gpgme a better way to detect corrupted data in the compression layer. GnuPG-bug-id: 6977
This commit is contained in:
parent
962058f704
commit
dcab895e4c
@ -53,7 +53,11 @@ init_compress( compress_filter_context_t *zfx, bz_stream *bzs )
|
||||
}
|
||||
|
||||
if((rc=BZ2_bzCompressInit(bzs,level,0,0))!=BZ_OK)
|
||||
log_fatal("bz2lib problem: %d\n",rc);
|
||||
{
|
||||
log_error ("bz2lib problem: %d\n",rc);
|
||||
write_status_error ("bzip2.init", gpg_error (GPG_ERR_INTERNAL));
|
||||
g10_exit (2);
|
||||
}
|
||||
|
||||
zfx->outbufsize = 8192;
|
||||
zfx->outbuf = xmalloc( zfx->outbufsize );
|
||||
@ -80,7 +84,11 @@ do_compress(compress_filter_context_t *zfx, bz_stream *bzs, int flush, IOBUF a)
|
||||
if( zrc == BZ_STREAM_END && flush == BZ_FINISH )
|
||||
;
|
||||
else if( zrc != BZ_RUN_OK && zrc != BZ_FINISH_OK )
|
||||
log_fatal("bz2lib deflate problem: rc=%d\n", zrc );
|
||||
{
|
||||
log_error ("bz2lib deflate problem: rc=%d\n", zrc );
|
||||
write_status_error ("bzip2.deflate", gpg_error (GPG_ERR_INTERNAL));
|
||||
g10_exit (2);
|
||||
}
|
||||
|
||||
n = zfx->outbufsize - bzs->avail_out;
|
||||
if( DBG_FILTER )
|
||||
@ -91,7 +99,7 @@ do_compress(compress_filter_context_t *zfx, bz_stream *bzs, int flush, IOBUF a)
|
||||
|
||||
if( (rc=iobuf_write( a, zfx->outbuf, n )) )
|
||||
{
|
||||
log_debug("bzCompress: iobuf_write failed\n");
|
||||
log_error ("bzCompress: iobuf_write failed\n");
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
@ -106,7 +114,11 @@ init_uncompress( compress_filter_context_t *zfx, bz_stream *bzs )
|
||||
int rc;
|
||||
|
||||
if((rc=BZ2_bzDecompressInit(bzs,0,opt.bz2_decompress_lowmem))!=BZ_OK)
|
||||
log_fatal("bz2lib problem: %d\n",rc);
|
||||
{
|
||||
log_error ("bz2lib problem: %d\n",rc);
|
||||
write_status_error ("bzip2.init.un", gpg_error (GPG_ERR_INTERNAL));
|
||||
g10_exit (2);
|
||||
}
|
||||
|
||||
zfx->inbufsize = 2048;
|
||||
zfx->inbuf = xmalloc( zfx->inbufsize );
|
||||
@ -159,7 +171,11 @@ do_uncompress( compress_filter_context_t *zfx, bz_stream *bzs,
|
||||
if( zrc == BZ_STREAM_END )
|
||||
rc = -1; /* eof */
|
||||
else if( zrc != BZ_OK && zrc != BZ_PARAM_ERROR )
|
||||
log_fatal("bz2lib inflate problem: rc=%d\n", zrc );
|
||||
{
|
||||
log_error ("bz2lib inflate problem: rc=%d\n", zrc );
|
||||
write_status_error ("bzip2.inflate", gpg_error (GPG_ERR_BAD_DATA));
|
||||
g10_exit (2);
|
||||
}
|
||||
else if (zrc == BZ_OK && eofseen
|
||||
&& !bzs->avail_in && bzs->avail_out > 0)
|
||||
{
|
||||
|
@ -73,10 +73,12 @@ init_compress( compress_filter_context_t *zfx, z_stream *zs )
|
||||
-13, 8, Z_DEFAULT_STRATEGY)
|
||||
: deflateInit( zs, level )
|
||||
) != Z_OK ) {
|
||||
log_fatal("zlib problem: %s\n", zs->msg? zs->msg :
|
||||
log_error ("zlib problem: %s\n", zs->msg? zs->msg :
|
||||
rc == Z_MEM_ERROR ? "out of core" :
|
||||
rc == Z_VERSION_ERROR ? "invalid lib version" :
|
||||
"unknown error" );
|
||||
write_status_error ("zlib.init", gpg_error (GPG_ERR_INTERNAL));
|
||||
g10_exit (2);
|
||||
}
|
||||
|
||||
zfx->outbufsize = 8192;
|
||||
@ -104,9 +106,11 @@ do_compress( compress_filter_context_t *zfx, z_stream *zs, int flush, IOBUF a )
|
||||
;
|
||||
else if( zrc != Z_OK ) {
|
||||
if( zs->msg )
|
||||
log_fatal("zlib deflate problem: %s\n", zs->msg );
|
||||
log_error ("zlib deflate problem: %s\n", zs->msg );
|
||||
else
|
||||
log_fatal("zlib deflate problem: rc=%d\n", zrc );
|
||||
log_error ("zlib deflate problem: rc=%d\n", zrc );
|
||||
write_status_error ("zlib.deflate", gpg_error (GPG_ERR_INTERNAL));
|
||||
g10_exit (2);
|
||||
}
|
||||
n = zfx->outbufsize - zs->avail_out;
|
||||
if( DBG_FILTER )
|
||||
@ -116,7 +120,7 @@ do_compress( compress_filter_context_t *zfx, z_stream *zs, int flush, IOBUF a )
|
||||
(unsigned)n, zrc );
|
||||
|
||||
if( (rc=iobuf_write( a, zfx->outbuf, n )) ) {
|
||||
log_debug("deflate: iobuf_write failed\n");
|
||||
log_error ("deflate: iobuf_write failed\n");
|
||||
return rc;
|
||||
}
|
||||
} while( zs->avail_in || (flush == Z_FINISH && zrc != Z_STREAM_END) );
|
||||
@ -140,10 +144,12 @@ init_uncompress( compress_filter_context_t *zfx, z_stream *zs )
|
||||
*/
|
||||
if( (rc = zfx->algo == 1? inflateInit2( zs, -15)
|
||||
: inflateInit( zs )) != Z_OK ) {
|
||||
log_fatal("zlib problem: %s\n", zs->msg? zs->msg :
|
||||
rc == Z_MEM_ERROR ? "out of core" :
|
||||
rc == Z_VERSION_ERROR ? "invalid lib version" :
|
||||
"unknown error" );
|
||||
log_error ("zlib problem: %s\n", zs->msg? zs->msg :
|
||||
rc == Z_MEM_ERROR ? "out of core" :
|
||||
rc == Z_VERSION_ERROR ? "invalid lib version" :
|
||||
"unknown error" );
|
||||
write_status_error ("zlib.init.un", gpg_error (GPG_ERR_INTERNAL));
|
||||
g10_exit (2);
|
||||
}
|
||||
|
||||
zfx->inbufsize = 2048;
|
||||
@ -198,9 +204,11 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs,
|
||||
rc = -1; /* eof */
|
||||
else if( zrc != Z_OK && zrc != Z_BUF_ERROR ) {
|
||||
if( zs->msg )
|
||||
log_fatal("zlib inflate problem: %s\n", zs->msg );
|
||||
log_error ("zlib inflate problem: %s\n", zs->msg );
|
||||
else
|
||||
log_fatal("zlib inflate problem: rc=%d\n", zrc );
|
||||
log_error ("zlib inflate problem: rc=%d\n", zrc );
|
||||
write_status_error ("zlib.inflate", gpg_error (GPG_ERR_BAD_DATA));
|
||||
g10_exit (2);
|
||||
}
|
||||
} while (zs->avail_out && zrc != Z_STREAM_END && zrc != Z_BUF_ERROR
|
||||
&& !leave);
|
||||
|
Loading…
x
Reference in New Issue
Block a user