Skip to content

Commit f10dfe9

Browse files
tabudzmvieth
authored andcommitted
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 130508f commit f10dfe9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

surface/src/3rdparty/opennurbs/inflate.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,10 @@ int flush;
682682
copy = state->length;
683683
if (copy > have) copy = have;
684684
if (copy) {
685+
len = state->head->extra_len - state->length;
685686
if (state->head != Z_NULL &&
686-
state->head->extra != Z_NULL) {
687-
len = state->head->extra_len - state->length;
687+
state->head->extra != Z_NULL &&
688+
len < state->head->extra_max) {
688689
zmemcpy(state->head->extra + len, next,
689690
len + copy > state->head->extra_max ?
690691
state->head->extra_max - len : copy);

0 commit comments

Comments
 (0)