Skip to content

Commit

Permalink
oidc_jose_zlib_uncompress: move error handling outside of loop
Browse files Browse the repository at this point in the history
Signed-off-by: Hans Zandbelt <hans.zandbelt@openidc.com>
  • Loading branch information
zandbelt committed Feb 16, 2024
1 parent d70666a commit 0168e9c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/jose.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ static apr_byte_t oidc_jose_zlib_uncompress(apr_pool_t *pool, const char *input,
return FALSE;
}

while (status != Z_STREAM_END) {
while (status == Z_OK) {
if (zlib.total_out >= OIDC_CJOSE_UNCOMPRESS_CHUNK) {
tmp = apr_pcalloc(pool, len + OIDC_CJOSE_UNCOMPRESS_CHUNK);
_oidc_memcpy(tmp, buf, len);
Expand All @@ -888,11 +888,12 @@ static apr_byte_t oidc_jose_zlib_uncompress(apr_pool_t *pool, const char *input,
zlib.next_out = (Bytef *)(buf + zlib.total_out);
zlib.avail_out = (uInt)len - zlib.total_out;
status = inflate(&zlib, Z_SYNC_FLUSH);
if ((status != Z_STREAM_END) && (status != Z_OK)) {
oidc_jose_error(err, "inflate() failed: %d", status);
inflateEnd(&zlib);
return FALSE;
}
}

if (status != Z_STREAM_END) {
oidc_jose_error(err, "inflate() failed: %d", status);
inflateEnd(&zlib);
return FALSE;
}

status = inflateEnd(&zlib);
Expand Down

0 comments on commit 0168e9c

Please sign in to comment.