Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 22 Apr 2015 21:26:57 -0400
From: Jean-Marc Pigeon <jmp@...e.ca>
To: musl@...ts.openwall.com
Subject: Re: setenv if value=NULL, what say standard? Bug?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/22/2015 08:35 PM, Laurent Bercot wrote:
> On 23/04/2015 02:08, Jean-Marc Pigeon wrote:
>> My guess, glibc code is 'blindly" setting the NULL (as "") value
>> to the variable.
>> 
>> Is the standard saying otherwise, or do we have a a real bug in
>> setenv??
> 
> The standard at 
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/setenv.html
>
> 
says...
> 
> ... exactly nothing about the possibility of envval being NULL. 
> This is, in the strictest sense, UB. :)
> 
> Actually, it says "The environment variable shall be set to the
> value to which envval points." So, arguably, envval should point to
> something, and since NULL does not, it is forbidden. Another valid
> interpretation could be that envvar is set to the value to which
> envval points, i.e. no value at all, so it is unset; but it doesn't
> fit the spirit of setenv() to unset variables. The glibc
> interpretation, if it does what you think it does, is wrong in any
> case: the empty string is a very different thing from no value at
> all.
> 
> I think the only safe conclusion is that the application is
> incorrect and should ensure that setenv() is never called with a
> NULL value.
> 
Checked glibc, My understanding, it set something as
"name="
in the environment, so the variable is present but
value is "empty"i (top application to decide what to do).
uclibc does something similar (as far I can tell looking
at source code)..


The application is not careful enough, but not incorrect as such.
Note: we may have tons of applications with the same problem.
if we keep musl setenv like that, musl will be seen as quite unreliable.

If this situation is indeed UB, there is 2 options for musl:
1) Swallow the problem nicely... as glibc and uclibc does.
2) Report an error.. EINVAL? (and document it in manual)

Crashing at "libc" level is not an option.



- -- 

A bientôt
===========================================================
Jean-Marc Pigeon                        E-Mail: jmp@...e.ca
SAFE Inc.                             Phone: (514) 493-4280
  Clement, 'a kiss solution' to get rid of SPAM (at last)
     Clement' Home base <"http://www.clement.safe.ca">
===========================================================
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJVOEphAAoJEAtgwJ4bBQU5ryMP/1p/gbq19bmhvWB8EWhuXQvC
tunPUHRmeM20J1RaEP437ISVUqcbzoiJAxiyrOBAZYQsM02I4+OPWlncYPfWfGgF
oqZ13GvvQn8rPGdBTDmSC5r2MSMI9na/FplWi638IjlKyehejJ/zzwMBszI7WA+H
6/wIgeTK1nh3Gegr6qSQmMcUBSH6GH5JLYqa1JAoN/YCi82JWyqAnnS/lZrfFH/2
HrQ2l4yFv8Ed9ofPJQ2Rz1h9if81zldqCyy2LXx8BZXEfaYdOOXpjoX9y71A671s
Cq/zj+nSWocZdLX5Bf1jFdXyvm5YXjQAsX5EMQ4nXdIFmcDZX5Z48+gU/PBgpRM2
+H7fy4aXW0eYSd7LlCVi/0Xf+p/YDm6JJCCNQCKArIUc14M/9Gl0+5y6quvwL8YX
tt8ffuj0F/OLwfQybd0pBLATFWsknsXdCA5ADPkDQ+YJIgx5UuHjediFRDo6ooCM
o0e5/yqHX3tWu9troJaxGNK0Ntm2eu0ZHSm1wuLE+lBKX5aqxCoKktTFMtD2Xk+Z
ZsBego9M79tCvWd76EalckwzjogJLDlMb5cKToJKxeZ6UyX56mIL8+SWPfZNTzy5
6P590SsBmdMC8mMv36sx54SpmIBQvaU21pp0a9LnJRba5JUmXIyWZR/1Srme2l6k
jA6srmhKxZH6mQ94qik/
=W3QH
-----END PGP SIGNATURE-----


Download attachment "smime.p7s" of type "application/pkcs7-signature" (4242 bytes)

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.