public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: DJ Delorie <dj@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] io: Fix silent readdir failures in ftw/nftw (BZ 33085)
Date: Mon, 20 Apr 2026 13:40:04 -0300	[thread overview]
Message-ID: <ae04fe83-569f-4eb8-9ff2-a25c481d32a9@linaro.org> (raw)
In-Reply-To: <xnqzod439n.fsf@greed.delorie.com>



On 17/04/26 19:43, DJ Delorie wrote:
> 
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
>> diff --git a/io/ftw.c b/io/ftw.c
>> @@ -246,8 +246,16 @@ open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp)
>>  	  struct dirent64 *d;
>>  	  size_t actsize = 0;
>>  
>> -	  while ((d = __readdir64 (st)) != NULL)
>> +	  while (1)
>>  	    {
>> +	      errno = 0;
>> +	      d = __readdir64 (st);
>> +	      if (d == NULL)
>> +		{
>> +		  if (errno != 0)
>> +		    return -1;
> 
> Need to free(buf) here.

Good catch.

> 
>> -	    frame->state = FTW_STATE_CLEANUP;
>> +	    {
>> +	      frame->state = FTW_STATE_CLEANUP;
>> +	      if (errno != 0)
>> +		result = -1;
> 
> And here.

This is is not really needed because the open_dir_stream entry will be
cleared in the FTW_STATE_CLEANUP state (the code does not return early,
but change the state to FTW_STATE_CLEANUP).

> 
>> diff --git a/io/tst-ftw-bz33085.c b/io/tst-ftw-bz33085.c
> 
>> +/* The test stress the readdir calls from nftw, where failures should not
> 
> typo : stress -> stresses

Ack.

> 
>> +   handled as end of stream.  The first it at 'ftw_dir'
> 
> s/it/is/
> 

Ack.

>> +   (FTW_STATE_STREAM_LOOP) for the default entries read.  The another one is
>> +   at open_dir_stream where it is triggered when there is a file description
>> +   exaustion and the code< must close an existing stream to make room for the
> 
> extra < ("code<")

Ack.

> 
> Rest looks OK.
> 


      reply	other threads:[~2026-04-20 16:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02 17:12 Adhemerval Zanella
2026-04-17 22:43 ` DJ Delorie
2026-04-20 16:40   ` Adhemerval Zanella Netto [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae04fe83-569f-4eb8-9ff2-a25c481d32a9@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=dj@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).