* environ.cc (build_env): Clear envblock and return NULL on attempt to use env
var > 32K. * spawn.cc (spawn_guts): Set E2BIG if build_env detects an error.
This commit is contained in:
parent
541ea31352
commit
e4d981b957
|
@ -1,3 +1,9 @@
|
|||
2005-09-16 Christopher Faylor <cgf@timesys.com>
|
||||
|
||||
* environ.cc (build_env): Clear envblock and return NULL on attempt to
|
||||
use env var > 32K.
|
||||
* spawn.cc (spawn_guts): Set E2BIG if build_env detects an error.
|
||||
|
||||
2005-09-16 Christopher Faylor <cgf@timesys.com>
|
||||
|
||||
* environ.cc (environ_init): Protect with a 'myfault' in case
|
||||
|
|
|
@ -1034,6 +1034,12 @@ build_env (const char * const *envp, char *&envblock, int &envc,
|
|||
p = *srcp; /* Don't worry about it */
|
||||
|
||||
len = strlen (p);
|
||||
if (len >= 32 * 1024 * 1024)
|
||||
{
|
||||
free (envblock);
|
||||
envblock = NULL;
|
||||
break;
|
||||
}
|
||||
new_tl += len + 1; /* Keep running total of block length so far */
|
||||
|
||||
/* See if we need to increase the size of the block. */
|
||||
|
@ -1066,7 +1072,6 @@ build_env (const char * const *envp, char *&envblock, int &envc,
|
|||
of buffer */
|
||||
}
|
||||
|
||||
|
||||
debug_printf ("envp %p, envc %d", newenv, envc);
|
||||
return newenv;
|
||||
}
|
||||
|
|
|
@ -624,6 +624,11 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
|||
cygheap->user.deimpersonate ();
|
||||
|
||||
moreinfo->envp = build_env (envp, envblock, moreinfo->envc, real_path.iscygexec ());
|
||||
if (!moreinfo->envp || !envblock)
|
||||
{
|
||||
set_errno (E2BIG);
|
||||
goto out;
|
||||
}
|
||||
ciresrv.set (chtype, real_path.iscygexec ());
|
||||
ciresrv.moreinfo = moreinfo;
|
||||
|
||||
|
|
Loading…
Reference in New Issue