public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/283] New: POSIX.1-2001: setenv called with envname containing = should fail
@ 2004-07-23 13:21 a dot josey at opengroup dot org
  2004-07-23 13:28 ` [Bug libc/283] " a dot josey at opengroup dot org
  2004-07-23 13:34 ` jakub at redhat dot com
  0 siblings, 2 replies; 3+ messages in thread
From: a dot josey at opengroup dot org @ 2004-07-23 13:21 UTC (permalink / raw)
  To: glibc-bugs

Reference 1003.1, 2004 edition p1306 l40983
If the envname argument points to a string containing an "=" character
then setenv() shall fail and set errno to EINVAL.

The following code checks that an environment variable "ENVVAR" is not
set and then calls setenv() with the envname argument "ENVVAR="
and the envval argument to to "VALUE2", it should fail returning
-1 and setting EINVAL but succeeds and sets the environment
variable to the value "=VALUE2"

#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

main()
{
int ret;
int err;
errno=0;
 
/* get the value */
printf ("Check that ENVVAR is not set in the environment\n");
printf ("ENVVAR expected \"(null)\" got \"%s\"\n", getenv("ENVVAR"));
 
/* set an environment name containing an = character */
printf ("call setenv() with envname set to \"ENVVAR=\" and envval set to
\"VALUE2\"\n");
errno=0;
ret=setenv("ENVVAR=", "VALUE2", 1);
/* should fail*/
err=errno;
if (ret != -1)
   {
        printf("setenv FAIL:expected to fail since envname contain an =
character\n");
        printf("errno=%d, expected EINVAL\n", err);
   }
printf ("ENVVAR expected \"(null)\" got \"%s\"\n", getenv("ENVVAR"));
 
}
 
$ make CC=c99 CFLAGS=-D_POSIX_C_SOURCE=200112L setenv
make: `setenv' is up to date.
-sh-2.05b$ ./setenv
Check that ENVVAR is not set in the environment
ENVVAR expected "(null)" got "(null)"
call setenv() with envname set to "ENVVAR=" and envval set to "VALUE2"
setenv FAIL:expected to fail since envname contain an = character
errno=0, expected EINVAL
ENVVAR expected "(null)" got "=VALUE2"

-- 
           Summary: POSIX.1-2001: setenv called with envname containing =
                    should fail
           Product: glibc
           Version: 2.3.2
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: a dot josey at opengroup dot org
                CC: glibc-bugs at sources dot redhat dot com


http://sources.redhat.com/bugzilla/show_bug.cgi?id=283

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/283] POSIX.1-2001: setenv called with envname containing = should fail
  2004-07-23 13:21 [Bug libc/283] New: POSIX.1-2001: setenv called with envname containing = should fail a dot josey at opengroup dot org
@ 2004-07-23 13:28 ` a dot josey at opengroup dot org
  2004-07-23 13:34 ` jakub at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: a dot josey at opengroup dot org @ 2004-07-23 13:28 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From a dot josey at opengroup dot org  2004-07-23 13:28 -------
Similarly calling setenv() with an envname set to an empty string succeeds when
it is expected to fail (return -1 and set errno to EINVAL)

setenv("", "value", 0);
setenv("", "value", 1)

When called with the first argument a null pointer, it should  also fail, but
instead segment faults.

-- 


http://sources.redhat.com/bugzilla/show_bug.cgi?id=283

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/283] POSIX.1-2001: setenv called with envname containing = should fail
  2004-07-23 13:21 [Bug libc/283] New: POSIX.1-2001: setenv called with envname containing = should fail a dot josey at opengroup dot org
  2004-07-23 13:28 ` [Bug libc/283] " a dot josey at opengroup dot org
@ 2004-07-23 13:34 ` jakub at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at redhat dot com @ 2004-07-23 13:34 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2004-07-23 13:34 -------
glibc 2.3.2 is way too old.
This has been fixed in CVS 1.5 months ago.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://sources.redhat.com/bugzilla/show_bug.cgi?id=283

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-07-23 13:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-23 13:21 [Bug libc/283] New: POSIX.1-2001: setenv called with envname containing = should fail a dot josey at opengroup dot org
2004-07-23 13:28 ` [Bug libc/283] " a dot josey at opengroup dot org
2004-07-23 13:34 ` jakub at redhat dot com

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 read-only IMAP folder(s) and NNTP newsgroup(s).