Skip to content

Commit ce7ed6e

Browse files
authored
Fix bug #47925 again (#14348)
The naming of the userland functions is terrible and confused me. gzdecode() is actually the function to decompress a gzip stream, and gzuncompress() is the one to decompress a deflate stream... See zlib.c to see the internal function -> type mapping.
1 parent 88ff32a commit ce7ed6e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

ext/soap/php_http.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,14 +1256,16 @@ int make_http_soap_request(zval *this_ptr,
12561256
zval retval;
12571257
zval params[1];
12581258

1259+
/* Warning: the zlib function names are chosen in an unfortunate manner.
1260+
* Check zlib.c to see how a function corresponds with a particular format. */
12591261
if ((strcmp(content_encoding,"gzip") == 0 ||
12601262
strcmp(content_encoding,"x-gzip") == 0) &&
1261-
zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) {
1262-
ZVAL_STRING(&func, "gzuncompress");
1263+
zend_hash_str_exists(EG(function_table), "gzdecode", sizeof("gzdecode")-1)) {
1264+
ZVAL_STRING(&func, "gzdecode");
12631265
ZVAL_STR_COPY(&params[0], http_body);
12641266
} else if (strcmp(content_encoding,"deflate") == 0 &&
1265-
zend_hash_str_exists(EG(function_table), "gzinflate", sizeof("gzinflate")-1)) {
1266-
ZVAL_STRING(&func, "gzinflate");
1267+
zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) {
1268+
ZVAL_STRING(&func, "gzuncompress");
12671269
ZVAL_STR_COPY(&params[0], http_body);
12681270
} else {
12691271
efree(content_encoding);

ext/soap/tests/bugs/bug47925.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ function test($compressed_response, $compression_name) {
3232
http_server_kill($pid);
3333
}
3434

35-
test(gzcompress($plain_response), "gzip");
36-
test(gzdeflate($plain_response), "deflate");
35+
test(gzencode($plain_response), "gzip");
36+
test(gzcompress($plain_response), "deflate");
3737
?>
3838
--EXPECT--
3939
int(7)

0 commit comments

Comments
 (0)