bug#17010: Bug#739752: coreutils: ln segfaults when run with --relative and an empty target

2014-03-14 Thread Pádraig Brady
On 03/14/2014 03:44 AM, Jim Meyering wrote:
 On Thu, Mar 13, 2014 at 7:22 PM, Pádraig Brady p...@draigbrady.com wrote:

 Interesting. So canonicalize_filename_mode() can fail in this case,
 even with CAN_MISSING. It's unexpected that c_f_m() sets errno=ENOENT
 when CAN_MISSING is set. I wonder should we change that instead
 in gnulib? With CAN_MISSING I would expect this function to work
 on arbitrary strings, including the empty string.
 
 What would you have c_f_m(, CAN_MISSING) return?
 I know of no absolute name corresponding to the dot-relative empty string.

Since with CAN_MISSING we should be just degenerating to string processing,
I would think it slightly better to return xstrdup(),
to avoid special casing that in each caller.

I also notice that c_f_m() can return ENOMEM (from areadlink_with_size).
It's arguable that we should xalloc_die() within c_f_m()
for consistency in that case.

However I also notice that c_f_m(, CAN_MISSING) can return ENOENT
if the current working dir is unlinked.  I'm not sure
there is anything else we could do within c_f_m() to handle that.

Hence since c_f_m() can validly fail even with CAN_MISSING,
I agree your patch is correct.

Please push.

thanks!
Pádraig.





bug#17010: Bug#739752: coreutils: ln segfaults when run with --relative and an empty target

2014-03-14 Thread Jim Meyering
On Fri, Mar 14, 2014 at 4:49 AM, Pádraig Brady p...@draigbrady.com wrote:
...
 Hence since c_f_m() can validly fail even with CAN_MISSING,
 I agree your patch is correct.

 Please push.

Done.