On Thu, Jan 19, 2012 at 10:17:02AM -0800, Philip Guenther wrote: > On Thu, Jan 19, 2012 at 4:18 AM, Edd Barrett <[email protected]> wrote: > > I recently got caught out by scandir's quirky memory allocation. Should > > we add a note so that others don't have to go through this pain too? > > Could you elaborate on how this affected your code? I'm trying to > think of some way for code to depend on this that isn't undefined > behavior by the POSIX standard and (sorry) just a bad idea in > practice...
I tried to memcpy() one of these dirents into a new buffer: memcpy(dest, src, sizeof(struct dirent)); This overran the read buffer, as most dirents allocated by scandir() are not this big. -- Best Regards Edd Barrett http://www.theunixzoo.co.uk
