summaryrefslogtreecommitdiffstats
path: root/php-bug78222.patch
blob: 13ea1d57849795b64d6f0b13aa2a4ad2f261a0c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Without test as binary patch not supported




From 13cbda640120afdaf68f44bb482723d451bc86ec Mon Sep 17 00:00:00 2001
From: Stanislav Malyshev <stas@php.net>
Date: Sun, 7 Jul 2019 17:01:01 -0700
Subject: [PATCH] Fix bug #78222 (heap-buffer-overflow on exif_scan_thumbnail)

(cherry picked from commit dea2989ab8ba87a6180af497b2efaf0527e985c5)
---
 ext/exif/exif.c              |   2 +-
 ext/exif/tests/bug78222.jpg  | Bin 0 -> 91 bytes
 ext/exif/tests/bug78222.phpt |  11 +++++++++++
 3 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 ext/exif/tests/bug78222.jpg
 create mode 100644 ext/exif/tests/bug78222.phpt

diff --git a/ext/exif/exif.c b/ext/exif/exif.c
index b6c31773ab..a5fa0b8fb0 100644
--- a/ext/exif/exif.c
+++ b/ext/exif/exif.c
@@ -3508,7 +3508,7 @@ static int exif_scan_thumbnail(image_info_type *ImageInfo TSRMLS_DC)
 	size_t          length=2, pos=0;
 	jpeg_sof_info   sof_info;
 
-	if (!data) {
+	if (!data || ImageInfo->Thumbnail.size < 4) {
 		return FALSE; /* nothing to do here */
 	}
 	if (memcmp(data, "\xFF\xD8\xFF", 3)) {