rocr: Fix Unintended Sign Extension

ehdr->e_shentshize and ehdr->e_shnum are both 16-bit unsigned integers
and so their types get implicitly promoted to signed int automatically
during the multiplication, they must be explicitly cast into a larger
unsigned type, otherwise if the signed product is large enough the
value is sign extended resulting in incorrect values.

Signed-off-by: Sunday Clement <Sunday.Clement@amd.com>


[ROCm/ROCR-Runtime commit: d00ca2e9b7]
이 커밋은 다음에 포함됨:
Sunday Clement 작성하고 Clement, Sunday가 2025-06-09 15:16:10 -04:00를 커밋함
1 부모 03430838af
커밋 1eaee1649a
1 파일이 변경됨
+1 -1
+1 -1
파일 보기
@@ -1738,7 +1738,7 @@ namespace elf {
}
uint64_t max_offset = ehdr->e_shoff;
uint64_t total_size = max_offset + ehdr->e_shentsize * ehdr->e_shnum;
uint64_t total_size = max_offset + static_cast<uint64_t>(ehdr->e_shentsize) * static_cast<uint64_t>(ehdr->e_shnum);
for (uint16_t i = 0; i < ehdr->e_shnum; ++i) {
uint64_t cur_offset = static_cast<uint64_t>(shdr[i].sh_offset);