Skip to content

Commit

Permalink
Fix ELF magic number comparison
Browse files Browse the repository at this point in the history
ELF magic number should be 127 ELF, and not have those extra numbers.

Signed-off-by: Giuliano Belinassi <[email protected]>
  • Loading branch information
giulianobelinassi committed Jan 25, 2023
1 parent 7392839 commit cddabd9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,13 @@ ulp_so_info_open(const char *path)
return NULL;
}

static const unsigned char elf_magic[] = { 127, 'E', 'L', 'F', 2, 1, 1, 0 };
unsigned char elf_header[16];
static const unsigned char elf_magic[] = { 127, 'E', 'L', 'F' };
unsigned char elf_header[5];

size_t n = fread(elf_header, 1, 16, f);
size_t n = fread(elf_header, 1, 5, f);
fclose(f);

if (n != 16) {
if (n != 5) {
return NULL;
}

Expand Down

0 comments on commit cddabd9

Please sign in to comment.