mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jean-Marc Pigeon <jmp@safe.ca>
To: musl@lists.openwall.com
Subject: Re: setenv if value=NULL, what say standard? Bug?
Date: Wed, 22 Apr 2015 21:26:57 -0400	[thread overview]
Message-ID: <55384A61.5020001@safe.ca> (raw)
In-Reply-To: <55383E43.8010505@skarnet.org>

[-- Attachment #1: Type: text/plain, Size: 3255 bytes --]

-----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@safe.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-----


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4242 bytes --]

  reply	other threads:[~2015-04-23  1:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-23  0:08 Jean-Marc Pigeon
2015-04-23  0:35 ` Laurent Bercot
2015-04-23  1:26   ` Jean-Marc Pigeon [this message]
2015-04-23  2:15     ` Rich Felker
2015-04-23  4:24       ` Jean-Marc Pigeon
2015-04-23  5:08         ` Raphael Cohn
2015-04-23 12:29           ` Jean-Marc Pigeon
2015-04-23  9:23         ` Laurent Bercot
2015-04-23  9:52           ` Raphael Cohn
2015-04-23 10:47             ` Laurent Bercot
2015-04-23 10:10         ` Rich Felker
2015-04-23 12:58           ` Jean-Marc Pigeon
2015-04-23 13:22             ` Szabolcs Nagy
2015-04-23 13:58               ` Jean-Marc Pigeon
2015-04-23 14:26                 ` Szabolcs Nagy
2015-04-23  8:05       ` Jens Gustedt
2015-04-23  9:55         ` Rich Felker
2015-04-24  4:11       ` Isaac Dunham
2015-04-23  5:52   ` Isaac Dunham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55384A61.5020001@safe.ca \
    --to=jmp@safe.ca \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).