diff options
| author | Mark Wielaard <[email protected]> | 2025-04-29 22:16:58 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2025-04-29 22:16:58 +0200 |
| commit | 04839d5826d21e7a603a76fddc7afed6d32ab087 (patch) | |
| tree | 9810e9e3af4ad071ebe2406135853cde295a44ab | |
| parent | 853c2943b582ac65fda6c28eaea21a1595fbaecd (diff) | |
ar: Check elf_getahdr doesn't return NULL
When elf_getahdr returns NULL we shouldn't even try to handle the ar
header, but immediately go to the next entry.
* src/ar.c (do_oper_extract): If elf_getahdr goto next.
(do_oper_delete): Likewise.
(do_oper_insert): Likewise.
Suggested-by: Anton Moryakov <[email protected]>
Signed-off-by: Mark Wielaard <[email protected]>
| -rw-r--r-- | src/ar.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -498,6 +498,8 @@ do_oper_extract (int oper, const char *arfname, char **argv, int argc, while ((subelf = elf_begin (fd, cmd, elf)) != NULL) { Elf_Arhdr *arhdr = elf_getarhdr (subelf); + if (arhdr == NULL) + goto next; if (strcmp (arhdr->ar_name, "/") == 0) { @@ -943,6 +945,8 @@ do_oper_delete (const char *arfname, char **argv, int argc, while ((subelf = elf_begin (fd, cmd, elf)) != NULL) { Elf_Arhdr *arhdr = elf_getarhdr (subelf); + if (arhdr == NULL) + goto next; /* Ignore the symbol table and the long file name table here. */ if (strcmp (arhdr->ar_name, "/") == 0 @@ -1152,6 +1156,8 @@ do_oper_insert (int oper, const char *arfname, char **argv, int argc, while ((subelf = elf_begin (fd, cmd, elf)) != NULL) { Elf_Arhdr *arhdr = elf_getarhdr (subelf); + if (arhdr == NULL) + goto next; /* Ignore the symbol table and the long file name table here. */ if (strcmp (arhdr->ar_name, "/") == 0 |
