[PATCH] io: Reject an empty path list on fts_open [BZ #25434] [BZ #34610]

Collin Funk collin.funk1@gmail.com
Sun Sep 13 06:59:28 GMT 2026


Florian Weimer <fweimer@redhat.com> writes:

> * Adhemerval Zanella Netto:
>
>> On 11/09/26 09:24, Florian Weimer wrote:
>>> * Adhemerval Zanella:
>>> 
>>>> An empty path list (argv[0] == NULL) yields an FTS handle that can not
>>>> be used.
>>> 
>>> Wouldn't it be conceptually clearer to succeed, but then do not offer up
>>> anything?
>> I am not sure, different implementation have different ideas:
>>
>> * FreeBSD/OpenBSD/Solaris returns NULL/EINVAL.
>> * macOS/musl returns an invalid handle that SEGFAULTS on next fts_read.
>>
>> This at least is a simpler fix, to follow your suggestion would be a bit
>> more complex and would make glibc different than rest.
>
> In this case:
>
> Reviewed-by: Florian Weimer <fweimer@redhat.com>
>
> Patch looks good.

I'm sort of surprised that bugs were filed for this, to be honest.

It seems like a case that should never happen. My understanding is that
fts invented for command line programs, see the comment which is also
included in fts.h from 4.4BSD Lite 2:

    #define FTS_COMFOLLOW 0x001  /* follow command line symlinks */

To me, it seems like this would only occur if no one checks if argc is
large enough such that argv has file names. In other words, a bug in
that program.

I guess there is no harm in making it a bit more graceful. So:

Reviewed-by: Collin Funk <collin.funk1@gmail.com>

Collin


More information about the Libc-alpha mailing list