mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
xen/efi: Rewrite DOS/PE magic checking without memcmp()
Misra Rule 21.16 doesn't like the use of memcmp() against character arrays (a string literal in this case). This is a rare piece of logic where we're looking for a magic marker that just happens to make sense when expressed as ASCII. Rewrite using plain compares. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Acked-by: Roger Pau Monné <roger.pau@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
02fbb2d591
commit
4cd66fb56d
1 file changed
+6
-2
+6
-2
@@ -111,7 +111,8 @@ const void *__init pe_find_section(const void *image, const UINTN image_size,
|
||||
UINTN offset, i;
|
||||
|
||||
if ( image_size < sizeof(*dos) ||
|
||||
memcmp(dos->Magic, "MZ", 2) != 0 )
|
||||
dos->Magic[0] != 'M' ||
|
||||
dos->Magic[1] != 'Z' )
|
||||
return NULL;
|
||||
|
||||
offset = dos->ExeHeader;
|
||||
@@ -119,7 +120,10 @@ const void *__init pe_find_section(const void *image, const UINTN image_size,
|
||||
|
||||
offset += sizeof(*pe);
|
||||
if ( image_size < offset ||
|
||||
memcmp(pe->Magic, "PE\0\0", 4) != 0 )
|
||||
pe->Magic[0] != 'P' ||
|
||||
pe->Magic[1] != 'E' ||
|
||||
pe->Magic[2] != '\0' ||
|
||||
pe->Magic[3] != '\0' )
|
||||
return NULL;
|
||||
|
||||
if ( pe->FileHeader.Machine != PE_HEADER_MACHINE )
|
||||
|
||||