Skip to content

Commit 4403ca4

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 393577c commit 4403ca4

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
@@ -713,6 +713,10 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
713713
if (tmp_line_len >= 1 &&tmp_line[tmp_line_len - 1] == '\r') {
714714
--tmp_line_len;
715715
}
716+
} else {
717+
// read and discard rest of status line
718+
char *line = php_stream_get_line(stream, NULL, 0, NULL);
719+
efree(line);
716720
}
717721
ZVAL_STRINGL(&http_response, tmp_line, tmp_line_len);
718722
zend_hash_next_index_insert(Z_ARRVAL_P(response_header), &http_response);

0 commit comments

Comments
 (0)