0002-fixed-a-incorrect-overflow-check.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. From 9266d14b5ca4e29b970fa03272318e5f99386e06 Mon Sep 17 00:00:00 2001
  2. From: Marcus Meissner <marcus@jet.franken.de>
  3. Date: Thu, 5 Nov 2020 09:50:08 +0100
  4. Subject: [PATCH] fixed a incorrect overflow check that could be optimized
  5. away.
  6. inspired by:
  7. https://android.googlesource.com/platform/external/libexif/+/8e7345f3bc0bad06ac369d6cbc1124c8ceaf7d4b
  8. https://source.android.com/security/bulletin/2020-11-01
  9. CVE-2020-0452
  10. Downloaded from upstream commit, rebased for 0.6.22:
  11. https://github.com/libexif/libexif/commit/9266d14b5ca4e29b970fa03272318e5f99386e06
  12. Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
  13. ---
  14. libexif/exif-entry.c | 4 ++--
  15. 1 file changed, 2 insertions(+), 2 deletions(-)
  16. diff --git a/libexif/exif-entry.c b/libexif/exif-entry.c
  17. index 3fc0ff9..4b866ce 100644
  18. --- a/libexif/exif-entry.c
  19. +++ b/libexif/exif-entry.c
  20. @@ -1371,8 +1371,8 @@ exif_entry_get_value (ExifEntry *e, char *val, unsigned int maxlen)
  21. {
  22. unsigned char *utf16;
  23. - /* Sanity check the size to prevent overflow */
  24. - if (e->size+sizeof(uint16_t)+1 < e->size) break;
  25. + /* Sanity check the size to prevent overflow. Note EXIF files are 64kb at most. */
  26. + if (e->size >= 65536 - sizeof(uint16_t)*2) break;
  27. /* The tag may not be U+0000-terminated , so make a local
  28. U+0000-terminated copy before converting it */