readlink segfaults (part 2)

Rob Landley rob at landley.net
Thu Jan 12 03:41:07 UTC 2006


On Wednesday 11 January 2006 16:35, Jonathan Lyster wrote:
> Note: the segfault I'm seeing only happens when I use the -f switch with
> readlink.

./busybox readlink -f switch_root
/home/landley/busybox/busybox/busybox

Note that we are relying on a glibc extension here.  The code does:
  buf=realpath(argv[optind], NULL);
  puts(buf);
  free(buf);

And the man page for realpath() says:

NOTES
       The glibc implementation of realpath() provides a  non-standard  exten‐
       sion.  If resolved_path is specified as NULL, then realpath() uses mal‐
       loc(3) to allocate a buffer to hold the resolved pathname, and  returns
       a  pointer  to  this  buffer.  The caller should deallocate this buffer
       using free(3).

What libc are you using?  (I tested that this would work with uClibc, but I 
don't remember which version I tested.)

Rob
-- 
Steve Ballmer: Innovation!  Inigo Montoya: You keep using that word.
I do not think it means what you think it means.



More information about the busybox mailing list