summaryrefslogtreecommitdiffstats
path: root/bug72735.patch
blob: eaa7e78ecab9bf05686c1f6e215913a4ef99c9ea (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From d5796fb298abb2a3e389818ad924589fa35e58b9 Mon Sep 17 00:00:00 2001
From: Kalle Sommer Nielsen <kalle@php.net>
Date: Wed, 3 Aug 2016 17:05:31 +0200
Subject: [PATCH] Changed the way MAKERNOTE is handled in case we do not have a
 matching signature (Remi).

Before this patch, exif_process_IFD_in_MAKERNOTE() would return false, then causing the rest of the EXIF parsing to be interrupted. This is a regression from earlier which was most likely a part of a security fix for MAKERNOTE.

The new behavior is to instead of stopping to parse, to continue so we can still fetch data like thumbnail and GPS, thrus allowing yet unsupported formats to parse. If EXIF's debugging mode is enabled, a notice will display in case we do not match against a valid MAKERNOTE signature.

This should temporarily fix bug #72682 (exif_read_data() fails to read all data for some images) until I get around to debug it further.

(cherry picked from commit aabcb5481d9e717df77192dab2894468b9fc63b4)
---
 ext/exif/exif.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/ext/exif/exif.c b/ext/exif/exif.c
index 5564de4..94652e9 100644
--- a/ext/exif/exif.c
+++ b/ext/exif/exif.c
@@ -1718,6 +1718,10 @@ static void exif_iif_add_value(image_info_type *image_info, int section_index, c
 			if (!length)
 				break;
 		case TAG_FMT_UNDEFINED:
+			if (tag == TAG_MAKER_NOTE) {
+				length = MIN(length, strlen(value));
+			}
+
 			if (value) {
 				/* do not recompute length here */
 				info_value->s = estrndup(value, length);
@@ -2733,8 +2737,14 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
 	char *dir_start;
 
 	for (i=0; i<=sizeof(maker_note_array)/sizeof(maker_note_type); i++) {
-		if (i==sizeof(maker_note_array)/sizeof(maker_note_type))
-			return FALSE;
+		if (i==sizeof(maker_note_array)/sizeof(maker_note_type)) {
+#ifdef EXIF_DEBUG
+			exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "No maker note data found. Detected maker: %s (length = %d)", ImageInfo->make, strlen(ImageInfo->make));
+#endif
+			/* unknown manufacturer, not an error, use it as a string */
+			return TRUE;
+		}
+
 		maker_note = maker_note_array+i;
 
 		/*exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "check (%s,%s)", maker_note->make?maker_note->make:"", maker_note->model?maker_note->model:"");*/
-- 
2.1.4

From 9667ee4f72c7dafce993b71104a52beb7c3aff15 Mon Sep 17 00:00:00 2001
From: Anatol Belski <ab@php.net>
Date: Wed, 3 Aug 2016 18:26:29 +0200
Subject: [PATCH] improve the check, avoid strlen on NULL

---
 ext/exif/exif.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ext/exif/exif.c b/ext/exif/exif.c
index 94652e9..f95de3a 100644
--- a/ext/exif/exif.c
+++ b/ext/exif/exif.c
@@ -1718,11 +1718,11 @@ static void exif_iif_add_value(image_info_type *image_info, int section_index, c
 			if (!length)
 				break;
 		case TAG_FMT_UNDEFINED:
-			if (tag == TAG_MAKER_NOTE) {
-				length = MIN(length, strlen(value));
-			}
-
 			if (value) {
+				if (tag == TAG_MAKER_NOTE) {
+					length = MIN(length, strlen(value));
+				}
+
 				/* do not recompute length here */
 				info_value->s = estrndup(value, length);
 				info_data->length = length;
-- 
2.1.4