mirror of
https://github.com/php/php-src.git
synced 2026-04-14 19:41:05 +02:00
Fix bug #75981: prevent reading beyond buffer start
This commit is contained in:
@@ -737,9 +737,9 @@ finish:
|
||||
tmp_line, response_code);
|
||||
}
|
||||
}
|
||||
if (tmp_line[tmp_line_len - 1] == '\n') {
|
||||
if (tmp_line_len >= 1 && tmp_line[tmp_line_len - 1] == '\n') {
|
||||
--tmp_line_len;
|
||||
if (tmp_line[tmp_line_len - 1] == '\r') {
|
||||
if (tmp_line_len >= 1 &&tmp_line[tmp_line_len - 1] == '\r') {
|
||||
--tmp_line_len;
|
||||
}
|
||||
}
|
||||
|
||||
32
ext/standard/tests/http/bug75981.phpt
Normal file
32
ext/standard/tests/http/bug75981.phpt
Normal file
@@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
Bug #75981 (stack-buffer-overflow while parsing HTTP response)
|
||||
--INI--
|
||||
allow_url_fopen=1
|
||||
--SKIPIF--
|
||||
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require 'server.inc';
|
||||
|
||||
$options = [
|
||||
'http' => [
|
||||
'protocol_version' => '1.1',
|
||||
'header' => 'Connection: Close'
|
||||
],
|
||||
];
|
||||
|
||||
$ctx = stream_context_create($options);
|
||||
|
||||
$responses = [
|
||||
"data://text/plain,000000000100\xA\xA"
|
||||
];
|
||||
$pid = http_server('tcp://127.0.0.1:12342', $responses);
|
||||
|
||||
echo @file_get_contents('http://127.0.0.1:12342/', false, $ctx);
|
||||
|
||||
http_server_kill($pid);
|
||||
|
||||
?>
|
||||
DONE
|
||||
--EXPECT--
|
||||
DONE
|
||||
Reference in New Issue
Block a user