* 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.
This commit is contained in:
Christopher Faylor 2006-09-07 20:42:53 +00:00
parent 0324070e35
commit d6b1ac7faa
3 changed files with 14 additions and 7 deletions

View File

@ -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.

View File

@ -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

View File

@ -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),