+2008-12-11 Roland McGrath <roland@redhat.com>
+
+ * offline.c (process_archive): Don't call elf_end and close if
+ returning NULL. Check first elf_begin call and set error code
+ specially for empty archive.
+ Fixes RHBZ#465878.
+
2008-12-02 Roland McGrath <roland@redhat.com>
* dwfl_getmodules.c (dwfl_getmodules): Typo fix in last change.
/* Recover relocatibility for addresses computed from debug information.
- Copyright (C) 2005, 2006, 2007 Red Hat, Inc.
+ Copyright (C) 2005, 2006, 2007, 2008 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
{
Dwfl_Module *mod = NULL;
+ Elf *member = elf_begin (fd, ELF_C_READ_MMAP_PRIVATE, archive);
+ if (unlikely (member == NULL)) /* Empty archive. */
+ {
+ __libdwfl_seterrno (DWFL_E_BADELF);
+ return NULL;
+ }
+
while (process_archive_member (dwfl, name, file_name, predicate,
- fd, elf_begin (fd, ELF_C_READ_MMAP_PRIVATE,
- archive), &mod) != ELF_C_NULL)
- ;
+ fd, member, &mod) != ELF_C_NULL)
+ member = elf_begin (fd, ELF_C_READ_MMAP_PRIVATE, archive);
/* We can drop the archive Elf handle even if we're still using members
in live modules. When the last module's elf_end on a member returns
zero, that module will close FD. If no modules survived the predicate,
we are all done with the file right here. */
- if (elf_end (archive) == 0)
+ if (mod != NULL /* If no modules, caller will clean up. */
+ && elf_end (archive) == 0)
close (fd);
return mod;