[PATCH] nftw: fill in stat buf for dangling links [BZ #23501]

DJ Delorie dj@redhat.com
Fri Jun 21 23:03:00 GMT 2019


Tulio Magno Quites Machado Filho <tuliom@ascii.art.br> writes:
>> +	  if (err < 0)
>> +	    {
>> +	      /* Stat failed.  We have three choices: don't report
>> +		 this file, report with invalid data, or report with
>> +		 zero'd data.  Let's prefer obvious over subtle so
>> +		 zero the data here.  This should happen extremely
>> +		 rarely.  */
>> +	      memset (&st, 0, sizeof (st));
>> +	    }
>
> I could not find a description of this behavior in the standard.

The spec doesn't cover it, so I defined it that way.  The only
alternative is to leave the buffer unchanged, which most likely would
report seemingly correct but invalid results.

The only time this happens is if we can know that a symlink exists in a
directory, but cannot read its stats.  I expect this to be exceedingly
rare.



More information about the Libc-alpha mailing list