_getenv_r patch

Howland Craig D (Craig) howland@LGSInnovations.com
Fri Sep 26 17:01:00 GMT 2008

Here's a patch for _getenv_r() so that it properly fails to make a match
if the given name contains an '='.  (Otherwise it can erroneously
match an entry which has an = in the value.)  The patch file contains
ChangeLog entry, too.
Craig Howland
The following program fragment demonstrates the problem being solved.

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

int  ow=1;
const char  *id, *val;

/* Tricky case */
id = "Craig";
val = "two=one";
ow = 1;
printf("setenv('%s','%s', %d) = %d\n", id, val, ow, setenv(id, val,
/* env now contains "Craig=two=one" */
printf("getenv('%s') = %s\n", id, getenv(id));	// Good match
id = "Craig=two";
printf("getenv('%s') = %s\n", id, getenv(id));	// Potential false match
-------------- next part --------------
A non-text attachment was scrubbed...
Name: genenv_r.patch
Type: application/octet-stream
Size: 1904 bytes
Desc: genenv_r.patch
URL: <http://sourceware.org/pipermail/newlib/attachments/20080926/8c3d577f/attachment.obj>

More information about the Newlib mailing list