This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: _getenv_r patch


Patch checked in. Thanks.

-- Jeff J.

Howland Craig D (Craig) wrote:
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
the
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,
ow));
/* 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]