content_encoding: give a clear error on multi-member gzip

A gzip Content-Encoding response holding more than one gzip member made
curl decode the first member and then fail the transfer with a bare
CURLE_WRITE_ERROR and no hint about the cause. Detect the trailing
member and fail with a message that explains what happened.

Fixes #22156
Closes #22172
This commit is contained in:
HwangRock 2026-06-25 22:00:04 +09:00 committed by Daniel Stenberg
parent 2b5911880b
commit df350dd0d8
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 70 additions and 1 deletions

View file

@ -206,6 +206,14 @@ static CURLcode inflate_stream(struct Curl_easy *data,
/* No more data to flush: exit loop. */
break;
case Z_STREAM_END:
if((started == ZLIB_INIT_GZIP) && (z->avail_in >= 2) &&
(z->next_in[0] == 0x1f) && (z->next_in[1] == 0x8b)) {
/* a second gzip member follows; curl does not support
multi-member gzip responses */
failf(data, "Multi-member gzip response not supported");
result = exit_zlib(data, z, &zp->zlib_init, CURLE_WRITE_ERROR);
break;
}
result = process_trailer(data, zp);
break;
case Z_DATA_ERROR: