From 9534e0d42d7476d6777f12806af940451c30078a Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 5 Jun 2024 11:15:36 +0300 Subject: [PATCH] Fix undefined behavior (left shift of negative number) Fixes oss-fuzz #69441 --- ext/standard/image.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/standard/image.c b/ext/standard/image.c index d064d9d4fd3..2bd5429efac 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -749,10 +749,10 @@ static signed short php_ifd_get16s(void *Short, int motorola_intel) static int php_ifd_get32s(void *Long, int motorola_intel) { if (motorola_intel) { - return ((unsigned)((( char *)Long)[0]) << 24) | (((unsigned char *)Long)[1] << 16) - | ((( char *)Long)[2] << 8 ) | (((unsigned char *)Long)[3] << 0 ); + return ((unsigned)(((unsigned char *)Long)[0]) << 24) | (((unsigned char *)Long)[1] << 16) + | (((unsigned char *)Long)[2] << 8 ) | (((unsigned char *)Long)[3] << 0 ); } else { - return ((unsigned)((( char *)Long)[3]) << 24) | (((unsigned char *)Long)[2] << 16) + return ((unsigned)(((unsigned char *)Long)[3]) << 24) | (((unsigned char *)Long)[2] << 16) | (((unsigned char *)Long)[1] << 8 ) | (((unsigned char *)Long)[0] << 0 ); } }