From d1ce9364f33654b87fa9bca7e096fd253f85d078 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 11 Jan 2005 12:42:35 +0000 Subject: [PATCH] * environ.cc (build_env): Disallow empty strings and strings starting with '=' in Win32 environment. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/environ.cc | 8 ++++++++ 2 files changed, 13 insertions(+) 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 + + * environ.cc (build_env): Disallow empty strings and strings starting + with '=' in Win32 environment. + 2005-01-08 Pierre Humblet * 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)