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
path: root/winsup
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
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')
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/environ.cc13
-rw-r--r--winsup/cygwin/errno.cc2
3 files changed, 14 insertions, 7 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 0982043ab..bdf457235 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2006-09-07 Christopher Faylor <cgf@timesys.com>
+
+ * 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.
+
2006-08-31 Corinna Vinschen <corinna@vinschen.de>
* grp.cc (initgroups32): Run get_server_groups under original token.
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
diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc
index e8beaa273..50819a952 100644
--- a/winsup/cygwin/errno.cc
+++ b/winsup/cygwin/errno.cc
@@ -87,7 +87,7 @@ static NO_COPY struct
X (MAX_THRDS_REACHED, EAGAIN),
X (META_EXPANSION_TOO_LONG, EINVAL),
X (MOD_NOT_FOUND, ENOENT),
- X (MORE_DATA, EAGAIN),
+ X (MORE_DATA, EMSGSIZE),
X (NEGATIVE_SEEK, EINVAL),
X (NETNAME_DELETED, ENOSHARE),
X (NOACCESS, EFAULT),