libexif/libexif-bugfix-unsigned-int.patch
2020-03-10 15:28:59 +08:00

31 lines
1.2 KiB
Diff

From cf37dc7934bbb10dc5d0c17db260a25aa2831595 Mon Sep 17 00:00:00 2001
From: Marcus Meissner <marcus@jet.franken.de>
Date: Sat, 18 Jan 2020 19:50:38 +0100
Subject: [PATCH] cast to unsigned int before shifting left
(weird integer promotion, a unsigned char will be first tried to be promoted to "int" apparently,
so we need to cast it to avoid implicit behaviour)
fixes https://github.com/libexif/libexif/issues/20
---
libexif/exif-utils.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libexif/exif-utils.c b/libexif/exif-utils.c
index 9083ddc..8a92907 100644
--- a/libexif/exif-utils.c
+++ b/libexif/exif-utils.c
@@ -132,9 +132,9 @@ exif_get_slong (const unsigned char *b, ExifByteOrder order)
if (!b) return 0;
switch (order) {
case EXIF_BYTE_ORDER_MOTOROLA:
- return ((b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]);
+ return (((uint32_t)b[0] << 24) | ((uint32_t)b[1] << 16) | ((uint32_t)b[2] << 8) | (uint32_t)b[3]);
case EXIF_BYTE_ORDER_INTEL:
- return ((b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0]);
+ return (((uint32_t)b[3] << 24) | ((uint32_t)b[2] << 16) | ((uint32_t)b[1] << 8) | (uint32_t)b[0]);
}
/* Won't be reached */