]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
isofs: avoid undefined timezone sign extension
authorStefan Reinauer <stefan.reinauer@coreboot.org>
Thu, 21 May 2026 00:37:36 +0000 (17:37 -0700)
committerStefan Reinauer <stefan.reinauer@coreboot.org>
Sun, 31 May 2026 07:33:15 +0000 (00:33 -0700)
make_date() sign-extends the ISO9660 timezone byte when the high
bit is set. (-1 << 8) shifts a negative signed value, which is
undefined behavior in C++.

Use ~0xff to build the same extension mask without relying on
that undefined shift.

isofs.cpp

index d40bd1b9312e035ecf15893cbae8982e453d2e2e..5fb47a305fdcfd61e697d90053f14e577a17b483 100644 (file)
--- a/isofs.cpp
+++ b/isofs.cpp
@@ -328,7 +328,7 @@ static int make_date(int year, int month, int day, int hour, int minute, int sec
 
                /* sign extend */
                if (tz & 0x80)
-                       tz |= (-1 << 8);
+                       tz |= ~0xff;
                
                /* 
                 * The timezone offset is unreliable on some disks,