[PATCH] acpi: acpidump: ensure we are shifting a 64 bit unsigned long

Colin King colin.king at canonical.com
Mon May 20 12:00:33 UTC 2013


From: Colin Ian King <colin.king at canonical.com>

Coverity CID#997275, Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)

To avoid 32 bit overflow, ensure 1 is a 64 bit unsigned long before
shifting it.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/acpi/acpidump/acpidump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/acpi/acpidump/acpidump.c b/src/acpi/acpidump/acpidump.c
index e509949..d95c166 100644
--- a/src/acpi/acpidump/acpidump.c
+++ b/src/acpi/acpidump/acpidump.c
@@ -101,7 +101,7 @@ static void acpi_dump_str(fwts_framework *fw, fwts_acpidump_field *info, void *d
 static uint64_t apci_dump_get_uint64_t(fwts_acpidump_field *info, void *data)
 {
 	uint64_t	ret;
-	uint64_t	mask = (1<<(uint64_t)info->bit_field_nbits) - 1;
+	uint64_t	mask = (1ULL<<(uint64_t)info->bit_field_nbits) - 1;
 	int i;
 
 	switch (info->size) {
-- 
1.8.1.2




More information about the fwts-devel mailing list