diff options
author | kientzle <kientzle@FreeBSD.org> | 2008-02-21 03:21:50 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2008-02-21 03:21:50 +0000 |
commit | 40e6cafd9c4de14423e21a13f22daff4b5244bbd (patch) | |
tree | 59350512b3cef6e60796edb8506db2f2080e1e0b /lib/libarchive/archive_write_set_compression_gzip.c | |
parent | c8e1e08fd3341dfcf79081e9256058e4341e89ec (diff) | |
download | FreeBSD-src-40e6cafd9c4de14423e21a13f22daff4b5244bbd.zip FreeBSD-src-40e6cafd9c4de14423e21a13f22daff4b5244bbd.tar.gz |
Sanity-check the block size.
Thanks to: Joerg Sonnenberger
MFC after: 7 days
Diffstat (limited to 'lib/libarchive/archive_write_set_compression_gzip.c')
-rw-r--r-- | lib/libarchive/archive_write_set_compression_gzip.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/libarchive/archive_write_set_compression_gzip.c b/lib/libarchive/archive_write_set_compression_gzip.c index b2e4f80..e4db651 100644 --- a/lib/libarchive/archive_write_set_compression_gzip.c +++ b/lib/libarchive/archive_write_set_compression_gzip.c @@ -106,6 +106,21 @@ archive_compressor_gzip_init(struct archive_write *a) return (ret); } + /* + * The next check is a temporary workaround until the gzip + * code can be overhauled some. The code should not require + * that compressed_buffer_size == bytes_per_block. Removing + * this assumption will allow us to compress larger chunks at + * a time, which should improve overall performance + * marginally. As a minor side-effect, such a cleanup would + * allow us to support truly arbitrary block sizes. + */ + if (a->bytes_per_block < 10) { + archive_set_error(&a->archive, EINVAL, + "GZip compressor requires a minimum 10 byte block size"); + return (ARCHIVE_FATAL); + } + state = (struct private_data *)malloc(sizeof(*state)); if (state == NULL) { archive_set_error(&a->archive, ENOMEM, @@ -114,6 +129,10 @@ archive_compressor_gzip_init(struct archive_write *a) } memset(state, 0, sizeof(*state)); + /* + * See comment above. We should set compressed_buffer_size to + * max(bytes_per_block, 65536), but the code can't handle that yet. + */ state->compressed_buffer_size = a->bytes_per_block; state->compressed = (unsigned char *)malloc(state->compressed_buffer_size); state->crc = crc32(0L, NULL, 0); |