Skip to content

Commit

Permalink
Fix a bug when getting a gzip header extra field with inflate().
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tabudz authored and mvieth committed Mar 4, 2025
1 parent 130508f commit f10dfe9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions surface/src/3rdparty/opennurbs/inflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,9 +682,10 @@ int flush;
copy = state->length;
if (copy > have) copy = have;
if (copy) {
len = state->head->extra_len - state->length;
if (state->head != Z_NULL &&
state->head->extra != Z_NULL) {
len = state->head->extra_len - state->length;
state->head->extra != Z_NULL &&
len < state->head->extra_max) {
zmemcpy(state->head->extra + len, next,
len + copy > state->head->extra_max ?
state->head->extra_max - len : copy);
Expand Down

0 comments on commit f10dfe9

Please sign in to comment.