Alejandro Colomar <[email protected]> writes:

> getenv(3) should also be included in that list, I believe.  It is also
> in ISO C, so you may want to change it already, in order to provide
> prior art for WG14.

Good catch. This one one is also likely to be misused. See the following
coreutils commit that was relatively recent:

    commit 2199c9003eafab7bab0f670d70e2869721e4813f
    Author:     Paul Eggert <[email protected]>
    AuthorDate: Sun Nov 23 11:42:57 2025 -0800
    Commit:     Paul Eggert <[email protected]>
    CommitDate: Sun Nov 23 12:00:09 2025 -0800
    
        du,ls: don’t modify getenv strings
        
        Fix du and ls to conform to the POSIX getenv spec,
        which says you can’t modify strings returned by getenv
        unless you put the string there directly, or used putenv.
        This portability bug was found by strict C23 checking
        using qualifier-generic functions.
        * bootstrap.conf (gnulib_modules): Add xmemdup0.  Sort.
        * src/du.c (main):
        * src/ls.c (decode_switches):
        Don’t modify the string that getenv returns.
        Instead, use xmemdup0 if needed, and include xmemdup0.h.

Collin

Reply via email to