Fix potential pointer overflows (#826)

Fix some potential pointer overflows in aot applying relocations and
several other places.
And add sanitizer compiler flags to wamrc CMakeLists.txt to detect
such issues.
This commit is contained in:
Wenyong Huang
2021-11-15 10:57:37 +08:00
committed by GitHub
parent a1ad950ae1
commit 64be6ec9a7
21 changed files with 103 additions and 65 deletions

View File

@ -2038,7 +2038,8 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
for (j = 0; j < relocation_count; j++) {
AOTRelocation relocation = { 0 };
uint32 symbol_index, offset32, addend32;
uint32 symbol_index, offset32;
int32 addend32;
uint16 symbol_name_len;
uint8 *symbol_name;
@ -2050,7 +2051,7 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
read_uint32(buf, buf_end, offset32);
relocation.relocation_offset = (uint64)offset32;
read_uint32(buf, buf_end, addend32);
relocation.relocation_addend = (uint64)addend32;
relocation.relocation_addend = (int64)addend32;
}
read_uint32(buf, buf_end, relocation.relocation_type);
read_uint32(buf, buf_end, symbol_index);