Browse Source

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
Wang, Gang 5 years ago
parent
commit
76f1ff4b24
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Pal/src/host/Linux-SGX/sgx_framework.c

+ 1 - 1
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];