lz4/zstd: Always check upper bid byte limit
If upstream filter provides huge amount of bytes, e.g. if archive is fully stored in memory, bidding accesses too many bytes. This could in turn overflow int return value, possibly leading to signed integer overflows. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
This commit is contained in:
1 parent
c2c5fffe1c
commit
978a9184ec
2 files changed
+4
-8
No files matched your search
@@ -205,13 +205,11 @@ lz4_reader_bid(struct archive_read_filter_bidder *b,
|
||||
* if this is LZ4 data.
|
||||
*/
|
||||
if (archive_ckd_add_size(&min,
|
||||
offset_in_buffer, min_lz4_frame_size))
|
||||
offset_in_buffer, min_lz4_frame_size) ||
|
||||
min > max_lookahead)
|
||||
return (0);
|
||||
/* TODO: should this be >= ? */
|
||||
if (min > (size_t)avail) {
|
||||
if (min > max_lookahead)
|
||||
return (0);
|
||||
|
||||
buffer = __archive_read_filter_ahead(f,
|
||||
min, &avail);
|
||||
if (buffer == NULL)
|
||||
|
||||
@@ -168,12 +168,10 @@ zstd_bidder_bid(struct archive_read_filter_bidder *b,
|
||||
* if this is zstd data.
|
||||
*/
|
||||
if (archive_ckd_add_size(&min,
|
||||
offset_in_buffer, min_zstd_frame_size))
|
||||
offset_in_buffer, min_zstd_frame_size) ||
|
||||
min > max_lookahead)
|
||||
return (0);
|
||||
if (min > (size_t)avail) {
|
||||
if (min > max_lookahead)
|
||||
return (0);
|
||||
|
||||
buffer = __archive_read_filter_ahead(f,
|
||||
min, &avail);
|
||||
if (buffer == NULL)
|
||||
|
||||
Reference in new issue
Block a user