From: Yu Watanabe Date: Mon, 28 Jul 2025 17:00:44 +0000 (+0900) Subject: efi-api: cast before shift X-Git-Tag: v258-rc2~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=be876c5933a5eb223565e70773746a4b49d49c9f;p=thirdparty%2Fsystemd.git 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' ``` --- diff --git a/src/shared/efi-api.c b/src/shared/efi-api.c index 73c09f66f6d..bbc410ca50f 100644 --- a/src/shared/efi-api.c +++ b/src/shared/efi-api.c @@ -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));