181150 |
02-Aug-2008 |
scf |
Detect if the application has cleared the environ variable by setting the first value (environ[0]) to NULL. This is in addition to the current detection of environ being replaced, which includes being set to NULL. Without this fix, the environment is not truly wiped, but appears to be by getenv() until an *env() call is made to alter the enviroment.
This change is necessary to support those applications that use this method for clearing environ such as Dovecot and Postfix. Applications such as Sendmail and the base system's env replace environ (already detected). While neither of these methods are defined by SUSv3, it is best to support them due to historic reasons and in lieu of a clean, defined method.
Add extra units tests for clearing environ using four different methods: 1. Set environ to NULL pointer. 2. Set environ[0] to NULL pointer. 3. Set environ to calloc()'d NULL-terminated array. 4. Set environ to static NULL-terminated array.
Noticed by: Timo Sirainen
MFC after: 3 days
|
176676 |
01-Mar-2008 |
scf |
Remove a dereference. It was unintended and a no-op.
Use the correct value of errno. Although the errno value passed into printf() follows the *env() call, it is not guaranteed to be the errno from that call. When I wrote the regression tester, the environment I used did pass the errno from the call. Consolidate the print for the return code and errno into a function in the process of fixing this.
Approved by: wes (mentor)
|
171525 |
20-Jul-2007 |
scf |
Added environ-replacement detection. For programs that "clean" (i.e., su) or replace (i.e., zdump) the environment after a call to setenv(), putenv() or unsetenv() has been made, a few changes were made. - getenv() will return the value from the new environ array. - setenv() was split into two functions: __setenv() which is most of the previous setenv() without checks on the name and setenv() which contains the checks before calling __setenv(). - setenv(), putenv() and unsetenv() will unset all previous values and call __setenv() on all entries in the new environ array which in turn adds them to the end of the envVars array. Calling __setenv() instead of setenv() is done to avoid the temporary replacement of the '=' in a string with a NUL byte. Some strings may be read-only data.
Added more regression checks for clearing the environment array.
Replaced gettimeofday() with getrusage() in timing regression check for better accuracy.
Fixed an off-by-one bug in __remove_putenv() in the use of memmove(). This went unnoticed due to the allocation of double the number of environ entries when building envVars.
Fixed a few spelling mistakes in the comments.
Reviewed by: ache Approved by: wes Approved by: re (kensmith)
|