pe-binary: fix array overrun

This is a kind of paranoia, as memeqzero() does not read anyting if
length is zero. But, strictly speaking C language does not allow such,
and Coverity warn about that.

Fixes CID#1561177.
This commit is contained in:
Yu Watanabe
2025-03-04 05:18:15 +09:00
parent 2bf5d698d6
commit 6529ab0b06
+1 -1
View File
@@ -58,7 +58,7 @@ const IMAGE_SECTION_HEADER* pe_section_table_find(
FOREACH_ARRAY(section, sections, n_sections)
if (memcmp(section->Name, name, n) == 0 &&
memeqzero(section->Name + n, sizeof(section->Name) - n))
(n == sizeof(sections[0].Name) || memeqzero(section->Name + n, sizeof(section->Name) - n)))
return section;
return NULL;