Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aH4ocg_nXSrWgEcC@cloudsdale.the-delta.net.eu.org>
Date: Mon, 21 Jul 2025 13:45:54 +0200
From: "Haelwenn (lanodan) Monnier" <contact@...ktivis.me>
To: musl@...ts.openwall.com
Cc: Rich Felker <dalias@...c.org>
Subject: Re: [PATCH 3/4] scandir: fix leaks caused by cancellation

[2025-07-21 03:08:14+0200] Luca Kellermann:
>On Sun, Jul 20, 2025 at 00:55:24AM -0400, Rich Felker wrote:
>> I'm unclear why they put such a non-normative note there rather than
>> normative text saying the behavior is undefined if these functions
>> don't satisfy their contract to return a value (and thereby, not to
>> cause cancellation to be acted upon, not call longjmp to leave the
>> caller's context, etc.). Maybe this should be opened as a bug against
>> the spec. For at least some of the other functions that take
>> callbacks, it's explicitly undefined if they don't return normally.
>
>If anyone files a bug, it could maybe also include these other issues
>I noticed when reading the spec for scandir():
>
>* The spec talks about "strings" but scandir() actually allocates and
>  returns dirent structures.
>* The RETURN VALUE section does not explicitly say that errno shall
>  be set on error.
>* The code in the EXAMPLES section calls free(namelist) even if
>  scandir() fails.
>* compar is not allowed to be a null pointer. That might be
>  intentional though.
>
>Luca

By the way, scandir() errorneously talking about "strings"
as well as free(namelist) has been addressed last week in
http://austingroupbugs.net/view.php?id=1931#c7222

Although free(NULL) is a no-op so free(namelist) should still
be fine in case of failure.

Best regards

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.