mirror of
https://github.com/php/php-src.git
synced 2025-08-19 17:04:47 +02:00
Fixed bug #68735 fileinfo out-of-bounds memory access
This commit is contained in:
parent
919abf0cb1
commit
ede59c8feb
4 changed files with 28 additions and 2 deletions
7
NEWS
7
NEWS
|
@ -4,6 +4,13 @@ PHP NEWS
|
||||||
- CGI:
|
- CGI:
|
||||||
. Fix bug #68618 (out of bounds read crashes php-cgi). (Stas)
|
. Fix bug #68618 (out of bounds read crashes php-cgi). (Stas)
|
||||||
|
|
||||||
|
- Fileinfo:
|
||||||
|
. Removed readelf.c and related code from libmagic sources
|
||||||
|
(Remi, Anatol)
|
||||||
|
. Fixed bug #68735 (fileinfo out-of-bounds memory access).
|
||||||
|
(Anatol)
|
||||||
|
|
||||||
|
|
||||||
18 Dec 2014 PHP 5.4.36
|
18 Dec 2014 PHP 5.4.36
|
||||||
|
|
||||||
- Core:
|
- Core:
|
||||||
|
|
|
@ -884,14 +884,17 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
|
||||||
size_t sz = file_pstring_length_size(m);
|
size_t sz = file_pstring_length_size(m);
|
||||||
char *ptr1 = p->s, *ptr2 = ptr1 + sz;
|
char *ptr1 = p->s, *ptr2 = ptr1 + sz;
|
||||||
size_t len = file_pstring_get_length(m, ptr1);
|
size_t len = file_pstring_get_length(m, ptr1);
|
||||||
if (len >= sizeof(p->s)) {
|
sz = sizeof(p->s) - sz; /* maximum length of string */
|
||||||
|
if (len >= sz) {
|
||||||
/*
|
/*
|
||||||
* The size of the pascal string length (sz)
|
* The size of the pascal string length (sz)
|
||||||
* is 1, 2, or 4. We need at least 1 byte for NUL
|
* is 1, 2, or 4. We need at least 1 byte for NUL
|
||||||
* termination, but we've already truncated the
|
* termination, but we've already truncated the
|
||||||
* string by p->s, so we need to deduct sz.
|
* string by p->s, so we need to deduct sz.
|
||||||
|
* Because we can use one of the bytes of the length
|
||||||
|
* after we shifted as NUL termination.
|
||||||
*/
|
*/
|
||||||
len = sizeof(p->s) - sz;
|
len = sz;
|
||||||
}
|
}
|
||||||
while (len--)
|
while (len--)
|
||||||
*ptr1++ = *ptr2++;
|
*ptr1++ = *ptr2++;
|
||||||
|
|
BIN
ext/fileinfo/tests/bug68735.jpg
Normal file
BIN
ext/fileinfo/tests/bug68735.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 B |
16
ext/fileinfo/tests/bug68735.phpt
Normal file
16
ext/fileinfo/tests/bug68735.phpt
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #68735 fileinfo out-of-bounds memory access
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$test_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "bug68735.jpg";
|
||||||
|
$f = new finfo;
|
||||||
|
|
||||||
|
var_dump($f->file($test_file));
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
string(%d) "JPEG image data, JFIF standard 1.01, comment: "%S""
|
||||||
|
===DONE===
|
Loading…
Add table
Add a link
Reference in a new issue