[Toybox] [PATCH] Fix 'cp -R' handling of symlinks
enh
enh at google.com
Sat Jan 10 14:27:48 PST 2015
On Sat, Jan 10, 2015 at 12:01 PM, Rob Landley <rob at landley.net> wrote:
> Again, PATH_MAX above. If somebody has a use case with a symlink longer
> than that, I can switch?
...
> I didn't do that because then it's a separate allocation requiring a
> separate free(). I can use it, it's just messy.
for all the bad things they did, one of the good things GNU did was
that they killed the fixed-length buffers so beloved of the AT&T guys.
it was the lack of arbitrary limits that would bite you at inopportune
moments that made me use GNU tools on proprietary unixes, not all the
useless extra options. and that was in a safer world where people
weren't actively trying to overflow them :-)
personally i'd rather we defaulted to the safe and obviously correct
code (in this case, xreadlink) and optimized the cases that turn out
to matter. so here, stat seems like a good candidate for "let's just
use xreadlink and forget about it". dirtree superficially doesn't
because it's library code, but that's exactly the reason why it should
--- the caller can't do anything. (and you're about to allocate
anyway.) (and if the need for a loop really upsets you, in both cases
you've already done a stat so you've got a better than usual initial
guess for the required buffer size.)
> I'm off to a corner to try to finish printf.c and sed.c, then I think
> the next pop off the stack is... the strtol() stuff? Or did I not finish
> the xstrncat() switchover? (Those notes are on the netbook...)
if you're going to use a strict stack, i'll abuse that by re-sending
stuff i care about more then :-)
--elliott
1420928868.0
More information about the Toybox
mailing list