summaryrefslogtreecommitdiffstats
path: root/libelf/elf_next.c
diff options
context:
space:
mode:
Diffstat (limited to 'libelf/elf_next.c')
-rw-r--r--libelf/elf_next.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libelf/elf_next.c b/libelf/elf_next.c
index ec80fadf..fbfb2721 100644
--- a/libelf/elf_next.c
+++ b/libelf/elf_next.c
@@ -64,6 +64,7 @@ elf_next (elf)
Elf *elf;
{
Elf *parent;
+ Elf_Cmd ret;
/* Be gratious, the specs demand it. */
if (elf == NULL || elf->parent == NULL)
@@ -73,14 +74,17 @@ elf_next (elf)
parent = elf->parent;
assert (parent->kind == ELF_K_AR);
+ rwlock_wrlock (parent->lock);
+
/* Now advance the offset. */
parent->state.ar.offset += (sizeof (struct ar_hdr)
+ ((parent->state.ar.elf_ar_hdr.ar_size + 1)
& ~1l));
/* Get the next archive header. */
- if (__libelf_next_arhdr (parent) != 0)
- return ELF_C_NULL;
+ ret = __libelf_next_arhdr_wrlock (parent) != 0 ? ELF_C_NULL : elf->cmd;
+
+ rwlock_unlock (parent->lock);
- return elf->cmd;
+ return ret;
}