Skip to content

Commit 71c9700

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: FIx bug #68618 (out of bounds read crashes php-cgi)
2 parents fbf3a6b + f9ad308 commit 71c9700

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
(CVE-2014-8142) (Stefan Esser)
1919
. Fixed bug #68676 (Explicit Double Free). (Kalle)
2020

21+
- CGI:
22+
. Fix bug #68618 (out of bounds read crashes php-cgi). (Stas)
23+
2124
- cURL:
2225
. Fixed bug #67643 (curl_multi_getcontent returns '' when
2326
CURLOPT_RETURNTRANSFER isn't set). (Jille Timmermans)

sapi/cgi/cgi_main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,14 +2434,17 @@ consult the installation file that came with this distribution, or visit \n\
24342434
int i = 1;
24352435

24362436
c = file_handle.handle.stream.mmap.buf[i++];
2437-
while (c != '\n' && c != '\r' && c != EOF) {
2437+
while (c != '\n' && c != '\r' && i < file_handle.handle.stream.mmap.len) {
24382438
c = file_handle.handle.stream.mmap.buf[i++];
24392439
}
24402440
if (c == '\r') {
2441-
if (file_handle.handle.stream.mmap.buf[i] == '\n') {
2441+
if (i < file_handle.handle.stream.mmap.len && file_handle.handle.stream.mmap.buf[i] == '\n') {
24422442
i++;
24432443
}
24442444
}
2445+
if(i > file_handle.handle.stream.mmap.len) {
2446+
i = file_handle.handle.stream.mmap.len;
2447+
}
24452448
file_handle.handle.stream.mmap.buf += i;
24462449
file_handle.handle.stream.mmap.len -= i;
24472450
}

0 commit comments

Comments
 (0)