From: Yu Watanabe Date: Tue, 18 Feb 2025 18:09:38 +0000 (+0900) Subject: pe-binary: fix array overrun X-Git-Tag: v258-rc1~1198^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6529ab0b066c93a6b8a8bf24b999d67e67a261f5;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/shared/pe-binary.c b/src/shared/pe-binary.c index d754ac1aa5f..6bfc4868aec 100644 --- a/src/shared/pe-binary.c +++ b/src/shared/pe-binary.c @@ -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;