On Sun, 2009-11-01 at 19:36 -0800, Roland McGrath wrote:
I tend to think the right fix is instead to have elf_next leave
ar.offset where it was in the failure case, so it changes nothing
at all.
That actually is already the case, for the public ar offset the user
gets from get_arroff(), even when elf_next() failed. Only the internal
state.ar.offset is changed, which isn't used till the user calls
elf_begin/elf_getarhdr(). So what my patch does is make sure it isn't
used at all when elf_next() failed and elf_begin() or elf_getarhdr() is
called subsequently (and it has the nice property of doing what Richard
expected).
I admit I also didn't know you were supposed to feed to result of
elf_next() into elf_begin(). That does make sense though. But it would
be nice if elf_begin() indicated end of archive even when given
ELF_C_READ, especially if there are other implementations doing that.
Cheers,
Mark