diff options
author | Sadaf Ebrahimi <sadafebrahimi@google.com> | 2022-12-06 23:14:20 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-12-06 23:14:20 +0000 |
commit | 35075bc1fa612ceebf1e0dde6e5c593d79e65753 (patch) | |
tree | c57c88c77fbc80b596ee8b71adf1bdb8a6ea1616 | |
parent | dc18fc32e1d3b35b578f1691a6ff92e40c82564b (diff) | |
parent | e5a6e35a651c42d3a813e24af1000a3163da8a1b (diff) | |
download | zlib-35075bc1fa612ceebf1e0dde6e5c593d79e65753.tar.gz |
Fix a bug when getting a gzip header extra field with inflate(). am: e5a6e35a65
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/zlib/+/20545899
Change-Id: I2fd5d67f6ec039124388ee0ddba6533b221f9220
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | contrib/optimizations/inflate.c | 5 | ||||
-rw-r--r-- | inflate.c | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/contrib/optimizations/inflate.c b/contrib/optimizations/inflate.c index 81d558b..93776ac 100644 --- a/contrib/optimizations/inflate.c +++ b/contrib/optimizations/inflate.c @@ -771,8 +771,9 @@ int flush; if (copy > have) copy = have; if (copy) { 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_len - state->length) < + state->head->extra_max) { zmemcpy(state->head->extra + len, next, len + copy > state->head->extra_max ? state->head->extra_max - len : copy); @@ -760,8 +760,9 @@ int flush; if (copy > have) copy = have; if (copy) { 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_len - state->length) < + state->head->extra_max) { zmemcpy(state->head->extra + len, next, len + copy > state->head->extra_max ? state->head->extra_max - len : copy); |