Commit 591f73e0 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Return error if nghttp2_gzip_inflate is invoked after Z_STREAM_END

parent 4d51def6
......@@ -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:
......
......@@ -33,6 +33,7 @@
struct nghttp2_gzip {
z_stream zst;
int8_t finished;
};
#endif /* NGHTTP2_GZIP_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment