Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit 0a6d266

Browse files
committed
Fix signed integer overflow on shift
Shifting a signed integer value of 1 by 31 or more bits will cause overflow and can lead to undefined behaviour. Fix this by adding a UL suffix to ensure an unsigned long is being shifted. Signed-off-by: Colin Ian King colin.king@canonical.com Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
1 parent bf768a4 commit 0a6d266

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sgx_encl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static u32 sgx_calc_ssaframesize(u32 miscselect, u64 xfrm)
339339
int i;
340340

341341
for (i = 2; i < 64; i++) {
342-
if (!((1 << i) & xfrm))
342+
if (!((1UL << i) & xfrm))
343343
continue;
344344

345345
size = SGX_SSA_GPRS_SIZE + sgx_xsave_size_tbl[i];

0 commit comments

Comments
 (0)