Skip to content

Commit 33a1ec1

Browse files
volcano0drlzha101
authored andcommitted
Fix integer overflow bug
Signed-off-by: volcano <volcano_dr@163.com>
1 parent 0471aae commit 33a1ec1

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

sdk/sign_tool/SignTool/manage_metadata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ bool CMetadata::build_layout_table()
12211221
// The memory reservation in emalloc.c also reserve two guard pages around the target
12221222
// memory region in each reservation, so we need an extra 0x10000B each time.
12231223
// Therefore, the total overhead should be (2^reserve_cnt - 1 + reserve_cnt) * 0x10000B.
1224-
uint64_t user_region_size = ((1 << reserve_cnt) - 1 + reserve_cnt) << 16;
1224+
uint64_t user_region_size = ((uint64_t)((1 << reserve_cnt) - 1 + reserve_cnt)) << 16;
12251225
se_trace(SE_TRACE_ERROR, "RTS bookkeeping overhead: 0x%016llX\n", user_region_size);
12261226

12271227
if (m_create_param.user_region_size > 0)

sdk/trts/ema_init.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int build_rts_context_nodes(layout_entry_t *entry, uint64_t offset)
4242
assert(IS_PAGE_ALIGNED(rva));
4343

4444
size_t addr = (size_t)get_enclave_base() + rva;
45-
size_t size = entry->page_count << SE_PAGE_SHIFT;
45+
size_t size = ((size_t)entry->page_count) << SE_PAGE_SHIFT;
4646

4747
// entry is guard page or has EREMOVE, build a reserved ema
4848
if ((entry->si_flags == 0) ||
@@ -83,8 +83,7 @@ static int build_rts_context_nodes(layout_entry_t *entry, uint64_t offset)
8383
commit_direction = SGX_EMA_GROWSDOWN;
8484
}
8585

86-
int ret = mm_alloc((void*)addr,
87-
((size_t)entry->page_count) << SE_PAGE_SHIFT,
86+
int ret = mm_alloc((void*)addr, size,
8887
SGX_EMA_COMMIT_ON_DEMAND | commit_direction
8988
| SGX_EMA_SYSTEM | SGX_EMA_FIXED | type,
9089
NULL, NULL, NULL);

0 commit comments

Comments
 (0)