Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2006-09-08 00:42:53 +0400
committerChristopher Faylor <me@cgf.cx>2006-09-08 00:42:53 +0400
commitd6b1ac7faa1f6c7a9e655add93dc8a31bfbc44df (patch)
treeb8741e836ad09f48bc1123b1f57ec714c42b56bd /winsup/cygwin/environ.cc
parent0324070e352783db45f2c2b9ab7c9af1edaf0ab1 (diff)
* environ.cc (build_env): Don't put an empty environment variable into the
environment. Optimize use of "len". * errno.cc (ERROR_MORE_DATA): Translate to EMSGSIZE rather than EAGAIN.
Diffstat (limited to 'winsup/cygwin/environ.cc')
-rw-r--r--winsup/cygwin/environ.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index c11a657d2..58b1e5070 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -1064,30 +1064,31 @@ build_env (const char * const *envp, char *&envblock, int &envc,
const char *p;
win_env *conv;
len = strcspn (*srcp, "=") + 1;
+ const char *rest = *srcp + len;
/* 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)
+ if (len == 1 || !*rest)
continue;
/* See if this entry requires posix->win32 conversion. */
- conv = getwinenv (*srcp, *srcp + len, &temp);
+ conv = getwinenv (*srcp, rest, &temp);
if (conv)
p = conv->native; /* Use win32 path */
else
p = *srcp; /* Don't worry about it */
- len = strlen (p);
+ len = strlen (p) + 1;
if (len >= 32 * 1024)
{
free (envblock);
envblock = NULL;
goto out;
}
- new_tl += len + 1; /* Keep running total of block length so far */
+ new_tl += len; /* Keep running total of block length so far */
/* See if we need to increase the size of the block. */
if (new_tl > tl)
@@ -1103,7 +1104,7 @@ build_env (const char * const *envp, char *&envblock, int &envc,
}
}
- memcpy (s, p, len + 1);
+ memcpy (s, p, len);
/* See if environment variable is "special" in a Windows sense.
Under NT, the current directories for visited drives are stored
@@ -1112,7 +1113,7 @@ build_env (const char * const *envp, char *&envblock, int &envc,
if (s[0] == '!' && (isdrive (s + 1) || (s[1] == ':' && s[2] == ':'))
&& s[3] == '=')
*s = '=';
- s += len + 1;
+ s += len;
}
*s = '\0'; /* Two null bytes at the end */
assert ((s - envblock) <= tl); /* Detect if we somehow ran over end