Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 1 | From 302acd49eba0a125b0f20692df6abc6f7f7ca53e Mon Sep 17 00:00:00 2001 |
| 2 | From: Changqing Li <changqing.li@windriver.com> |
| 3 | Date: Wed, 30 Dec 2020 10:18:51 +0800 |
| 4 | Subject: [PATCH] fixed a incorrect overflow check that could be optimized |
| 5 | away. |
| 6 | |
| 7 | inspired by: |
| 8 | https://android.googlesource.com/platform/external/libexif/+/8e7345f3bc0bad06ac369d6cbc1124c8ceaf7d4b |
| 9 | |
| 10 | https://source.android.com/security/bulletin/2020-11-01 |
| 11 | |
| 12 | CVE-2020-0452 |
| 13 | |
| 14 | Upsteam-Status: Backport[https://github.com/libexif/libexif/commit/9266d14b5ca4e29b970fa03272318e5f99386e06] |
| 15 | CVE: CVE-2020-0452 |
| 16 | |
| 17 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
| 18 | --- |
| 19 | libexif/exif-entry.c | 4 ++-- |
| 20 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 21 | |
| 22 | diff --git a/libexif/exif-entry.c b/libexif/exif-entry.c |
| 23 | index 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 | -- |
| 38 | 2.17.1 |
| 39 | |