CRiSP Blog

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


Read more http://crtags.blogspot.com/2010/09/elfcntlelfcfdread-is-broken.html

Testimonials

"After using Brief for many years, I did not look forward to learning vi or Emacs on my UNIX machine. CRiSP came to the rescue. The program has now grown and matured to the point where it has become much better than Brief ever was."

paypal_horiz