Hi, while looking through the cegcc project, I discovered a few issues with the setenv() (_setenv_r) and getenv() (_getenv_r) functions:
1. In the beginning of the function, the pointer to the value string is shifted if the string starts with '='. The comment says that is to prevent values to start from '='. I couldn't find anywhere in the definition of setenv() that a value may not start with equal character. Any reason for eating first equal character up? 2. The setenv() man pages seem to ask for returning EINVAL in case there is an equal character inside the name of the variable. It also says that glibc versions do allow to have environment variable names with equal signs in them, however, the current implementation of environment variables in newlib doesn't seem to be able to distinguish between those. (So, if you set variable named (a=b) with value (c), the getenv for (a) will return (b=c)). So I believe newlibs setenv should return EINVAL. 3. The getenv() implementation searches for the variables that have the name as passed, unless the name contains an equal sign in it, in which case, the only part that is searched for is the characters before the equal sign. So if you call setenv("foo", "bar", 1) and then call getenv("foo=grape"), you will get "foo=bar" as the result of that getenv call. Since cegcc project uses newlib for base library support, I'm cross-posting to both lists. Would appreciate any comments on the above. I can produce a patch that restricts both functions to POSIX behavior. Thanks, Pawel. -- With best of best regards Pawel S. Veselov ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Cegcc-devel mailing list Cegcc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cegcc-devel