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

"CRiSP is the best programmers text editor I have ever used. It is great for programming, script writing, and editing huge text files. It has made me much more efficient at file manipulation and has made my work tasks much easier."

paypal_horiz