Skip to content

Commit e648fa4

Browse files
smalyshevcmb69
authored andcommitted
Fix bug #78256 (heap-buffer-overflow on exif_process_user_comment)
(cherry picked from commit aeb6d13)
1 parent f22101c commit e648fa4

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ PHP NEWS
33
?? ??? ????, PHP 7.3.8
44

55
- EXIF:
6+
. Fixed bug #78256 (heap-buffer-overflow on exif_process_user_comment).
7+
(CVE-2019-11042) (Stas)
68
. Fixed bug #78222 (heap-buffer-overflow on exif_scan_thumbnail).
79
(CVE-2019-11041) (Stas)
810

ext/exif/exif.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3015,11 +3015,11 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
30153015
/* First try to detect BOM: ZERO WIDTH NOBREAK SPACE (FEFF 16)
30163016
* since we have no encoding support for the BOM yet we skip that.
30173017
*/
3018-
if (!memcmp(szValuePtr, "\xFE\xFF", 2)) {
3018+
if (ByteCount >=2 && !memcmp(szValuePtr, "\xFE\xFF", 2)) {
30193019
decode = "UCS-2BE";
30203020
szValuePtr = szValuePtr+2;
30213021
ByteCount -= 2;
3022-
} else if (!memcmp(szValuePtr, "\xFF\xFE", 2)) {
3022+
} else if (ByteCount >=2 && !memcmp(szValuePtr, "\xFF\xFE", 2)) {
30233023
decode = "UCS-2LE";
30243024
szValuePtr = szValuePtr+2;
30253025
ByteCount -= 2;

ext/exif/tests/bug78256.jpg

69 Bytes
Loading

ext/exif/tests/bug78256.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #78256 (heap-buffer-overflow on exif_process_user_comment)
3+
--SKIPIF--
4+
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
5+
--FILE--
6+
<?php
7+
@exif_read_data(__DIR__."/bug78256.jpg", 'COMMENT', FALSE, TRUE);
8+
?>
9+
DONE
10+
--EXPECTF--
11+
DONE

0 commit comments

Comments
 (0)