mirror of
https://github.com/intel/isa-l.git
synced 2025-02-25 07:41:06 +01:00
igzip: Fix bug when 0 length buffer is passed
Avoid unsigned addition overflow when avail_in = 0 and next_in = -1 causing a comparison to be correct when it should not be. Change-Id: I3ff7123a89867317f383931cc95c8738ba2f8d56 Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
parent
de7d639ab1
commit
13692d61a3
@ -125,6 +125,7 @@ void isal_deflate_finish_base(struct isal_zstream *stream)
|
||||
end_in = start_in + stream->avail_in;
|
||||
next_in = start_in;
|
||||
|
||||
if (stream->avail_in != 0) {
|
||||
while (next_in + 3 < end_in) {
|
||||
if (is_full(&state->bitbuf)) {
|
||||
update_state(stream, start_in, next_in, end_in);
|
||||
@ -137,7 +138,8 @@ void isal_deflate_finish_base(struct isal_zstream *stream)
|
||||
last_seen[hash] = (uint64_t) (next_in - state->file_start);
|
||||
|
||||
if (dist - 1 < IGZIP_HIST_SIZE - 1) { /* The -1 are to handle the case when dist = 0 */
|
||||
match_length = compare258(next_in - dist, next_in, end_in - next_in);
|
||||
match_length =
|
||||
compare258(next_in - dist, next_in, end_in - next_in);
|
||||
|
||||
if (match_length >= SHORTEST_MATCH) {
|
||||
next_hash = next_in;
|
||||
@ -157,7 +159,8 @@ void isal_deflate_finish_base(struct isal_zstream *stream)
|
||||
|
||||
get_len_code(stream->hufftables, match_length, &code,
|
||||
&code_len);
|
||||
get_dist_code(stream->hufftables, dist, &code2, &code_len2);
|
||||
get_dist_code(stream->hufftables, dist, &code2,
|
||||
&code_len2);
|
||||
|
||||
code |= code2 << code_len;
|
||||
code_len += code_len2;
|
||||
@ -188,6 +191,7 @@ void isal_deflate_finish_base(struct isal_zstream *stream)
|
||||
next_in++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_full(&state->bitbuf)) {
|
||||
get_lit_code(stream->hufftables, 256, &code, &code_len);
|
||||
|
Loading…
x
Reference in New Issue
Block a user