Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: putenv/setenv changes



In article <20101002224932.GB23377%apb-laptoy.apb.alt.za@localhost>,
Alan Barrett  <apb%cequrux.com@localhost> wrote:
>On Sat, 02 Oct 2010, Matthias Scheler wrote:
>> Modified Files:
>>      src/lib/libc/stdlib: putenv.c setenv.c
>> 
>> Log Message:
>> Restore binary compatibility with application which use putenv(3) on
>> contant strings (e.g. postdrop(1)):
>> - Don't write to the environment string passed to putenv(3).
>> - Don't overwrite the value of an existing in setenv(3) unless the memory
>>   was actually allocated by setenv(3).
>
>Please document this.
>
>I suggest a BUGS section in putenv(3) stating that that the interface
>uses non-const char* for compatibility with POSIX brain damage, but the
>implementation guarantees to treat it as read-only.

Actually the string must be writeable because POSIX requires you
to use the actual string passed to putenv() inside the environment
array. All strings in the environment array must be writable. I am
ambivalent about the binary compatibility restoration, because
while it fixes the common case, it might break programs that use
both putenv and setenv (hopefully none).

christos



Home | Main Index | Thread Index | Old Index