efi-api: cast before shift

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'
```
This commit is contained in:
Yu Watanabe
2025-07-29 02:00:44 +09:00
committed by Luca Boccassi
parent 9fa08842b7
commit be876c5933

View 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));