[Bug 268479] lib/libc/stdlib/getenv.c may have a problem with putenv()

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 21 Dec 2022 02:08:06 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268479

--- Comment #1 from Dennis Clarke <dclarke@blastwave.org> ---

As a follow up I have been carefully reading : 

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08

Section 8.1 Environment Variable Definition which does not seem to care
if the value of an env var is the empty string '\0';  Therefore UNAME_s
can be just an empty string and then of course we see the uname struct
member for system get set to the empty string.

Section 8.1 Environment Variable Definition states : 

    These strings have the form name=value; names shall not contain
    the character '='. For values to be portable across systems
    conforming to POSIX.1-2017, the value shall be composed of
    characters from the portable character set (except NUL and as
    indicated below). 

I see there "except NUL" for the value.  However putenv and setenv
both allow the value to be just a NUL byte '\0'; That then results
in the name=value being name=NUL. 

Is it reasonable to allow this behavior given the POSIX spec ? 


Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional

-- 
You are receiving this mail because:
You are the assignee for the bug.