diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/environ.cc | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 1192a06f4..dea1593f3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2005-01-11 Corinna Vinschen <corinna@vinschen.de> + + * environ.cc (build_env): Disallow empty strings and strings starting + with '=' in Win32 environment. + 2005-01-08 Pierre Humblet <pierre.humblet@ieee.org> * syscalls.cc (seteuid32): Only change the default dacl when diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 4b15df253..8605cf2e6 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -957,6 +957,14 @@ build_env (const char * const *envp, char *&envblock, int &envc, win_env *conv; len = strcspn (*srcp, "=") + 1; + /* Check for a bad entry. This is necessary to get rid of empty + strings, induced by putenv and changing the string afterwards. + Note that this doesn't stop invalid strings without '=' in it + etc., but we're opting for speed here for now. Adding complete + checking would be pretty expensive. */ + if (len == 1) + continue; + /* See if this entry requires posix->win32 conversion. */ conv = getwinenv (*srcp, *srcp + len); if (conv) |