Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFGcq_5UhvrpW-9N3nmOn3V9QjPAKZGWUdTMEit4Syx=W6qEfg@mail.gmail.com>
Date: Sat, 12 Jul 2025 08:22:13 +0200
From: Luca Kellermann <mailto.luca.kellermann@...il.com>
To: Thorsten Glaser <tg@...bsd.de>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH 1/4] scandir: hide that errno is set to 0

On Fri, Jul 11, 2025 at 07:15:20PM +0000, Thorsten Glaser wrote:
> Luca Kellermann dixit:
>
> >+              if (sel) {
> >+                      /* sel() must not observe that errno was set to 0. */
> >+                      errno = old_errno;
> >+                      if (!sel(de)) continue;
> >+              }
>
> Should this not restore errrno to 0 for the next code?

The other functions called in the loop (realloc(), malloc(), memcpy())
shouldn't care about the value of errno. The controlling expression of
the while loop already takes care of setting errno to 0 before calling
readdir() again:

    while ((errno=0), (de = readdir(d))) {

Luca

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.