Skip to content

Commit eff308a

Browse files
author
Mark Adler
committed
Fix a bug when getting a gzip header extra field with inflate().
If the extra field was larger than the space the user provided with inflateGetHeader(), and if multiple calls of inflate() delivered the extra header data, then there could be a buffer overflow of the provided space. This commit assures that provided space is not exceeded.
1 parent b8bd098 commit eff308a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

inflate.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,10 @@ int flush;
763763
copy = state->length;
764764
if (copy > have) copy = have;
765765
if (copy) {
766+
len = state->head->extra_len - state->length;
766767
if (state->head != Z_NULL &&
767-
state->head->extra != Z_NULL) {
768-
len = state->head->extra_len - state->length;
768+
state->head->extra != Z_NULL &&
769+
len < state->head->extra_max) {
769770
zmemcpy(state->head->extra + len, next,
770771
len + copy > state->head->extra_max ?
771772
state->head->extra_max - len : copy);

0 commit comments

Comments
 (0)