From 76f1ff4b242da69454ee5eccf0965f33a8923103 Mon Sep 17 00:00:00 2001 From: "Wang, Gang" Date: Wed, 17 Oct 2018 04:57:34 -0700 Subject: [PATCH] No suffix to integer literals cause overflow (#251) a left shift operator applys on a literal number 1 cause overflow so unsigned long long type suffix should be appended to that literal that makes it has same type as xfrm and xfrm for safety --- Pal/src/host/Linux-SGX/sgx_framework.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pal/src/host/Linux-SGX/sgx_framework.c b/Pal/src/host/Linux-SGX/sgx_framework.c index c4ea9f0e..66b98b95 100644 --- a/Pal/src/host/Linux-SGX/sgx_framework.c +++ b/Pal/src/host/Linux-SGX/sgx_framework.c @@ -90,7 +90,7 @@ static size_t get_ssaframesize (uint64_t xfrm) xfrm_ex = ((uint64_t) cpuinfo[3] << 32) + cpuinfo[2]; for (int i = 2; i < 64; i++) - if ((xfrm & (1 << i)) || (xfrm_ex & (1 << i))) { + if ((xfrm & (1ULL << i)) || (xfrm_ex & (1ULL << i))) { cpuid(0xd, i, cpuinfo); if (cpuinfo[0] + cpuinfo[1] > xsave_size) xsave_size = cpuinfo[0] + cpuinfo[1];