Refine is_xip_file and pointer range check (#965)

Refine is_xip_file check, when e_type isn't E_TYPE_XIP, just return false
and no need to go through all the other sections of the AOT file.

Refine pointer range check, convert pointer to uintptr_t type before
comparison to yield possible sanitizer pointer overflow error.
This commit is contained in:
Wenyong Huang
2022-01-18 11:05:58 +08:00
committed by GitHub
parent 552f85075d
commit 8088783775
4 changed files with 20 additions and 17 deletions

View File

@ -90,7 +90,8 @@ static bool
check_buf(const uint8 *buf, const uint8 *buf_end, uint32 length,
char *error_buf, uint32 error_buf_size)
{
if (buf + length < buf || buf + length > buf_end) {
if ((uintptr_t)buf + length < (uintptr_t)buf
|| (uintptr_t)buf + length > (uintptr_t)buf_end) {
set_error_buf(error_buf, error_buf_size, "unexpect end");
return false;
}