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 <amerey@redhat.com>
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;