diff --git a/lib/nghttp2_gzip.c b/lib/nghttp2_gzip.c index e472ec7f..c22cba94 100644 --- a/lib/nghttp2_gzip.c +++ b/lib/nghttp2_gzip.c @@ -33,6 +33,7 @@ int nghttp2_gzip_inflate_new(nghttp2_gzip **inflater_ptr) if(*inflater_ptr == NULL) { return NGHTTP2_ERR_NOMEM; } + (*inflater_ptr)->finished = 0; (*inflater_ptr)->zst.next_in = Z_NULL; (*inflater_ptr)->zst.avail_in = 0; (*inflater_ptr)->zst.zalloc = Z_NULL; @@ -59,6 +60,9 @@ int nghttp2_gzip_inflate(nghttp2_gzip *inflater, const uint8_t *in, size_t *inlen_ptr) { int rv; + if(inflater->finished) { + return NGHTTP2_ERR_GZIP; + } inflater->zst.avail_in = *inlen_ptr; inflater->zst.next_in = (unsigned char*)in; inflater->zst.avail_out = *outlen_ptr; @@ -69,8 +73,9 @@ int nghttp2_gzip_inflate(nghttp2_gzip *inflater, *inlen_ptr -= inflater->zst.avail_in; *outlen_ptr -= inflater->zst.avail_out; switch(rv) { - case Z_OK: case Z_STREAM_END: + inflater->finished = 1; + case Z_OK: case Z_BUF_ERROR: return 0; case Z_DATA_ERROR: diff --git a/lib/nghttp2_gzip.h b/lib/nghttp2_gzip.h index 6f309c89..ca2a5655 100644 --- a/lib/nghttp2_gzip.h +++ b/lib/nghttp2_gzip.h @@ -33,6 +33,7 @@ struct nghttp2_gzip { z_stream zst; + int8_t finished; }; #endif /* NGHTTP2_GZIP_H */