Skip to content

Commit ae1db2c

Browse files
committed
Fix GH-9316: $http_response_header is wrong for long status line
While the reason-phrase in a HTTP response status line is usually short, there is no actual limit specified by the RFCs. As such, we must not assume that the line fits into the buffer (which is currently 128 bytes large). Since there is no real need to present the complete status line, we simply read and discard the rest of a long line.
1 parent 05ed47e commit ae1db2c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ext/standard/http_fopen_wrapper.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,10 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
717717
if (tmp_line_len >= 1 &&tmp_line[tmp_line_len - 1] == '\r') {
718718
--tmp_line_len;
719719
}
720+
} else {
721+
// read and discard rest of status line
722+
char *line = php_stream_get_line(stream, NULL, 0, NULL);
723+
efree(line);
720724
}
721725
ZVAL_STRINGL(&http_response, tmp_line, tmp_line_len);
722726
zend_hash_next_index_insert(Z_ARRVAL_P(response_header), &http_response);

0 commit comments

Comments
 (0)