]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
efi-api: cast before shift
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 28 Jul 2025 17:00:44 +0000 (02:00 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 28 Jul 2025 18:10:26 +0000 (19:10 +0100)
Fixes the following error when running with sanitizers:
```
TEST-87-AUX-UTILS-VM.sh[670]: + bootctl install --make-entry-directory=yes
TEST-87-AUX-UTILS-VM.sh[695]: Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi.signed" to "/boot/EFI/systemd/systemd-bootx64.efi".
TEST-87-AUX-UTILS-VM.sh[695]: Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi.signed" to "/boot/EFI/BOOT/BOOTX64.EFI".
TEST-87-AUX-UTILS-VM.sh[695]: Created "/boot/fedora".
TEST-87-AUX-UTILS-VM.sh[695]: Random seed file /boot/loader/random-seed successfully refreshed (32 bytes).
TEST-87-AUX-UTILS-VM.sh[695]: ../src/shared/efi-api.c:618:38: runtime error: left shift of 243 by 24 places cannot be represented in type 'int'
```

src/shared/efi-api.c

index 73c09f66f6d9915ecfba84f0254837dd38b3843c..bbc410ca50fbd59a22ac9bd95a03ebc5d7790ea8 100644 (file)
@@ -615,9 +615,9 @@ void efi_id128_to_guid(sd_id128_t id, void *ret_guid) {
         assert(ret_guid);
 
         EFI_GUID uuid = {
-                .Data1 = id.bytes[0] << 24 | id.bytes[1] << 16 | id.bytes[2] << 8 | id.bytes[3],
-                .Data2 = id.bytes[4] << 8 | id.bytes[5],
-                .Data3 = id.bytes[6] << 8 | id.bytes[7],
+                .Data1 = (uint32_t) id.bytes[0] << 24 | (uint32_t) id.bytes[1] << 16 | (uint32_t) id.bytes[2] << 8 | id.bytes[3],
+                .Data2 = (uint16_t) id.bytes[4] << 8 | id.bytes[5],
+                .Data3 = (uint16_t) id.bytes[6] << 8 | id.bytes[7],
         };
         memcpy(uuid.Data4, id.bytes+8, sizeof(uuid.Data4));
         memcpy(ret_guid, &uuid, sizeof(uuid));