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

"I was given the job of finding the best UNIX programmers editor on the market to oem with our product. I installed and worked with all the packages I could find. CRiSP text editor was easily the best solution available."

paypal_horiz