From f80ad18afae2230c2c1802c7d829100af646874e Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Mon, 29 Apr 2019 23:38:12 -0700 Subject: [PATCH] Fix bug #77950 - Heap-buffer-overflow in _estrndup via exif_process_IFD_TAG I do not completely understand what is going on there, but I am pretty sure dir_entry <= offset_base if not a normal situation, so we better not to rely on such dir_entry. --- NEWS | 11 +++++++++-- ext/exif/exif.c | 2 +- ext/exif/tests/bug77950.phpt | 12 ++++++++++++ ext/exif/tests/bug77950.tiff | Bin 0 -> 1267 bytes 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 ext/exif/tests/bug77950.phpt create mode 100644 ext/exif/tests/bug77950.tiff diff --git a/NEWS b/NEWS index f529a71116c..70ad9a7a6fb 100644 --- a/NEWS +++ b/NEWS @@ -2,13 +2,20 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2019, PHP 7.1.29 +- EXIF +. Fixed bug #77950 (Heap-buffer-overflow in _estrndup via exif_process_IFD_TAG). + (CVE-2019-11036) (Stas) +- Mail +. Fixed bug #77821 (Potential heap corruption in TSendMail()). (cmb) 04 Apr 2019, PHP 7.1.28 - EXIF: - . Fixed bug #77753 (Heap-buffer-overflow in php_ifd_get32s). (Stas) - . Fixed bug #77831 (Heap-buffer-overflow in exif_iif_add_value). (Stas) + . Fixed bug #77753 (Heap-buffer-overflow in php_ifd_get32s). (CVE-2019-11034) + (Stas) + . Fixed bug #77831 (Heap-buffer-overflow in exif_iif_add_value). + (CVE-2019-11035) (Stas) - SQLite3: . Added sqlite3.defensive INI directive. (BohwaZ) diff --git a/ext/exif/exif.c b/ext/exif/exif.c index a763f6c77b0..d174def80c1 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -2891,7 +2891,7 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha offset_base is ImageInfo->file.list[sn].data-dir_offset dir_entry - offset_base is dir_offset+2+i*12 */ - if (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry || offset_val < (size_t)(dir_entry-offset_base)) { + if (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry || offset_val < (size_t)(dir_entry-offset_base) || dir_entry <= offset_base) { /* It is important to check for IMAGE_FILETYPE_TIFF * JPEG does not use absolute pointers instead its pointers are * relative to the start of the TIFF header in APP1 section. */ diff --git a/ext/exif/tests/bug77950.phpt b/ext/exif/tests/bug77950.phpt new file mode 100644 index 00000000000..dc0f3549cbc --- /dev/null +++ b/ext/exif/tests/bug77950.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #77950 (Heap-buffer-overflow in _estrndup via exif_process_IFD_TAG) +--SKIPIF-- + +--FILE-- + +DONE +--EXPECTF-- +%A +DONE \ No newline at end of file diff --git a/ext/exif/tests/bug77950.tiff b/ext/exif/tests/bug77950.tiff new file mode 100644 index 0000000000000000000000000000000000000000..5c8250ab04a255e9552d5a798c5a36e5dfa4ec94 GIT binary patch literal 1267 zcmebD)MDUZU|`^8;A3QCPyn*Bfta6>NkIZgZvtWgMka=@%nS^tfNW+)P6kCF%?QL& zjI3b#8ju~%$ijFJNP~a|RJ}cr4N?zMgslD_P+XXa`TutytqH`L?JQtN_( zeIk7WLW30=Jl#D*9DNj=9erJc92H=I!8bE6Kc^&7N5R|Q&(qma!PnEz-zUV8!P(MG zD@w=3#LOUy!GodU*?*wf9zb`4?1q^MGRwsis3-9cP!t3Vf~*V;tqd9z&YeGc?)1?! z#~CCUW;H>4X2Hb3Fc-@10J3W)u`?(DjRS=j$0Uf!3_u&WCOrY$f=dl21JnQi|Ct0t zfcl`m2djSvK$nSlUvAWU0zbuI;k zoQmAMVylYW0$cTrlG*|*ef_**J)mV!Fn!vDxv6@|`MLTPi3R$`dItJDNT3J72D%yu zzM}{2f9eLU12AZnI+%WfA}ZL+Gg$XOuYn2Fsf2EN?fQ+Iw^$xOdHU@6i5&sYsD6bdK|Fqic^$uB!wCA7!JYvC>TOa! literal 0 HcmV?d00001