alpha/boot/tools/objstrip: fix the check for ELF header
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 9 Jan 2023 05:14:02 +0000 (00:14 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 11 Jan 2023 20:36:46 +0000 (15:36 -0500)
Just memcmp() with ELFMAG - that's the normal way to do it in userland
code, which that thing is.  Besides, that has the benefit of actually
building - str_has_prefix() is *NOT* present in <string.h>.

Fixes: 5f14596e55de "alpha: Replace strncmp with str_has_prefix"
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/alpha/boot/tools/objstrip.c

index 08b430d25a315ff07d37e5e95e6dbda9048f8183..7cf92d172dce901057992bcbd7be1308e221e4f3 100644 (file)
@@ -148,7 +148,7 @@ main (int argc, char *argv[])
 #ifdef __ELF__
     elf = (struct elfhdr *) buf;
 
-    if (elf->e_ident[0] == 0x7f && str_has_prefix((char *)elf->e_ident + 1, "ELF")) {
+    if (memcmp(&elf->e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) {
        if (elf->e_type != ET_EXEC) {
            fprintf(stderr, "%s: %s is not an ELF executable\n",
                    prog_name, inname);