]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
iso9660.h: avoid undefined signed integer shift
authorThomas Weißschuh <thomas@t-8ch.de>
Tue, 13 Dec 2022 02:40:02 +0000 (02:40 +0000)
committerThomas Weißschuh <thomas@t-8ch.de>
Thu, 15 Dec 2022 02:22:09 +0000 (02:22 +0000)
When the high bit in p[3] is set we would overflow our signed 4-byte
integer result value.
Force an unsigned type instead.

include/iso9660.h

index cbc45dbb47524bb952491b62ed7f17e6cfd98c7d..ed402d8c80652c539df8de3e6b6262afd8454117 100644 (file)
@@ -34,7 +34,7 @@ static inline uint32_t isonum_731(const unsigned char *p)
        return ((p[0] & 0xff)
                | ((p[1] & 0xff) << 8)
                | ((p[2] & 0xff) << 16)
-               | ((p[3] & 0xff) << 24));
+               | (((uint32_t) p[3] & 0xff) << 24));
 }
 
 static inline uint32_t isonum_732(const unsigned char *p)
@@ -42,7 +42,7 @@ static inline uint32_t isonum_732(const unsigned char *p)
        return ((p[3] & 0xff)
                | ((p[2] & 0xff) << 8)
                | ((p[1] & 0xff) << 16)
-               | ((p[0] & 0xff) << 24));
+               | (((uint32_t) p[0] & 0xff) << 24));
 }
 
 static inline uint32_t isonum_733(const unsigned char *p, bool check_match)