Monday 6 September 2010

elf_cntl(ELF_C_FDREAD) is broken


#include
#include
#include
#include

int main(int argc, char **argv)
{ int fd;
Elf *elf;
int err;

elf_version(EV_CURRENT);
fd = open(argv[1], O_RDONLY);
elf = elf_begin(fd, ELF_C_READ, NULL);
err = elf_cntl(elf, ELF_C_FDREAD);

printf("elf=%p err=%d\n", elf, err);
}


Interestingly, the elf_cntl tries to do a malloc(-1) but fails.
Seems to be a buggy libelf.a on Ubuntu 10.04 - it forgets to fstat()
the original file and ends up thinking the size of the file is ~0.

Annoying, valgrind catches this (complains of a silly malloc(-1)), but doesnt
tell you where this happens, despite it being ever so important.



Post created by CRiSP v10.0.2a-b5887


No comments:

Post a Comment