[PATCH] realpath stack usage 12k -> 8k

Denys Vlasenko vda.linux at googlemail.com
Sun Dec 2 10:44:43 UTC 2007


Hi,

Currently busybox's biggest stack user (per-function)
is actually in uclibc, not busybox. It's realpath().

Proposed patch uses user-supplied buffer directly,
without intermediate on-stack copy.
This can only make a difference if user supplied
a buffer which is too small - thus user breaks API.

Failure scenario:

realpath("/link_name", user_buffer)

/link_name -> /very_long_name_which_fits_into_PATH_MAX_and_is_also_a_link ->
-> /shorter_name

If user will give e.g. 40-char user_buffer, current implementation
will work, patched one will overflow user_buffer by intermediate name.

This should not be a problem - user must supply PATH_MAX sized buffer,
and in this case patched version also works correctly.

Run tested.

ACK, anyone?
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: realpath.diff
Type: text/x-diff
Size: 2209 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20071202/58543ce0/attachment-0002.bin 


More information about the uClibc mailing list