diff options
| author | Aaron Merey <[email protected]> | 2025-01-30 20:16:11 -0500 |
|---|---|---|
| committer | Aaron Merey <[email protected]> | 2025-02-07 17:13:51 -0500 |
| commit | 78bdee7cb881b6b6df23872d898458fa4b486ac0 (patch) | |
| tree | 7070e546fa000e04fdff995195e8599bf249f0c3 | |
| parent | 6c76ce7331e82a6fc6c2004e8e6ae51ca91f51d7 (diff) | |
libdwfl/offline.c: Avoid closing invalid fd
process_archive may be called with an fd argument of -1, which
libelf interprets as "no file opened". However when closing
the fd process_archive does not check whether the fd is valid
and may attempt to close an fd of -1.
Signed-off-by: Aaron Merey <[email protected]>
| -rw-r--r-- | libdwfl/offline.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libdwfl/offline.c b/libdwfl/offline.c index 24e9e180..dc099d2b 100644 --- a/libdwfl/offline.c +++ b/libdwfl/offline.c @@ -271,7 +271,8 @@ process_archive (Dwfl *dwfl, const char *name, const char *file_name, int fd, zero, that module will close FD. If no modules survived the predicate, we are all done with the file right here. */ if (mod != NULL /* If no modules, caller will clean up. */ - && elf_end (archive) == 0) + && elf_end (archive) == 0 + && fd >= 0) close (fd); return mod; |
