com php-src: Fix OOB read introduced by previous commit: ext/standard/http_fopen_wrapper.c
| From: | Nikita Popov | Date: | Sat, 07 Jan 2017 23:01:05 +0000 |
| Subject: | com php-src: Fix OOB read introduced by previous commit: ext/standard/http_fopen_wrapper.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96616@lists.php.net to get a copy of this message | ||
Commit: ec1b7b933d630cd02e3998a211eda40a9e4e7ce3
Author: Nikita Popov <nikic@php.net> Sun, 8 Jan 2017 00:01:05 +0100
Parents: 5146d9f8ac170d8ba7109370d732d56dc0777578
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ec1b7b933d630cd02e3998a211eda40a9e4e7ce3
Log:
Fix OOB read introduced by previous commit
Ooops...
Changed paths:
M ext/standard/http_fopen_wrapper.c
Diff:
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index 1ed7dc2..1822566 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -122,7 +122,6 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
char *ua_str = NULL;
zval *ua_zval = NULL, *tmpzval = NULL, ssl_proxy_peer_name;
size_t scratch_len = 0;
- int body = 0;
char location[HTTP_HEADER_BLOCK_SIZE];
zval response_header;
int reqok = 0;
@@ -753,7 +752,7 @@ finish:
http_header_line = emalloc(HTTP_HEADER_BLOCK_SIZE);
- while (!body && !php_stream_eof(stream)) {
+ while (!php_stream_eof(stream)) {
size_t http_header_line_length;
if (php_stream_get_line(stream, http_header_line, HTTP_HEADER_BLOCK_SIZE,
&http_header_line_length) && *http_header_line != '\n' &&
*http_header_line != '\r') {
@@ -769,7 +768,7 @@ finish:
} while (*e != '\n');
continue;
}
- while (*e == '\n' || *e == '\r') {
+ while (e >= http_header_line && (*e == '\n' || *e == '\r')) {
e--;
}
@@ -779,7 +778,7 @@ finish:
* > optional trailing whitespace. */
/* Strip trailing whitespace */
- while (*e == ' ' || *e == '\t') {
+ while (e >= http_header_line && (*e == ' ' || *e == '\t')) {
e--;
}