blob: a117b8b36917cce4b0c909abdd867b3a3df6add1 [file] [log] [blame]
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001From 302acd49eba0a125b0f20692df6abc6f7f7ca53e Mon Sep 17 00:00:00 2001
2From: Changqing Li <changqing.li@windriver.com>
3Date: Wed, 30 Dec 2020 10:18:51 +0800
4Subject: [PATCH] fixed a incorrect overflow check that could be optimized
5 away.
6
7inspired by:
8https://android.googlesource.com/platform/external/libexif/+/8e7345f3bc0bad06ac369d6cbc1124c8ceaf7d4b
9
10https://source.android.com/security/bulletin/2020-11-01
11
12CVE-2020-0452
13
14Upsteam-Status: Backport[https://github.com/libexif/libexif/commit/9266d14b5ca4e29b970fa03272318e5f99386e06]
15CVE: CVE-2020-0452
16
17Signed-off-by: Changqing Li <changqing.li@windriver.com>
18---
19 libexif/exif-entry.c | 4 ++--
20 1 file changed, 2 insertions(+), 2 deletions(-)
21
22diff --git a/libexif/exif-entry.c b/libexif/exif-entry.c
23index 5de215f..3a6ce84 100644
24--- a/libexif/exif-entry.c
25+++ b/libexif/exif-entry.c
26@@ -1371,8 +1371,8 @@ exif_entry_get_value (ExifEntry *e, char *val, unsigned int maxlen)
27 {
28 unsigned char *utf16;
29
30- /* Sanity check the size to prevent overflow */
31- if (e->size+sizeof(uint16_t)+1 < e->size) break;
32+ /* Sanity check the size to prevent overflow. Note EXIF files are 64kb at most. */
33+ if (e->size >= 65536 - sizeof(uint16_t)*2) break;
34
35 /* The tag may not be U+0000-terminated , so make a local
36 U+0000-terminated copy before converting it */
37--
382.17.1
39