Skip to content

Commit f9ad308

Browse files
committed
FIx bug #68618 (out of bounds read crashes php-cgi)
1 parent cd387b4 commit f9ad308

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 20?? PHP 5.4.37
4+
- CGI:
5+
. Fix bug #68618 (out of bounds read crashes php-cgi). (Stas)
46

57
18 Dec 2014 PHP 5.4.36
68

sapi/cgi/cgi_main.c

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

24312431
c = file_handle.handle.stream.mmap.buf[i++];
2432-
while (c != '\n' && c != '\r' && c != EOF) {
2432+
while (c != '\n' && c != '\r' && i < file_handle.handle.stream.mmap.len) {
24332433
c = file_handle.handle.stream.mmap.buf[i++];
24342434
}
24352435
if (c == '\r') {
2436-
if (file_handle.handle.stream.mmap.buf[i] == '\n') {
2436+
if (i < file_handle.handle.stream.mmap.len && file_handle.handle.stream.mmap.buf[i] == '\n') {
24372437
i++;
24382438
}
24392439
}
2440+
if(i > file_handle.handle.stream.mmap.len) {
2441+
i = file_handle.handle.stream.mmap.len;
2442+
}
24402443
file_handle.handle.stream.mmap.buf += i;
24412444
file_handle.handle.stream.mmap.len -= i;
24422445
}

0 commit comments

Comments
 (0)