if we are using ssp, use malloc instead of alloca.

This commit is contained in:
christos 2006-11-08 23:27:32 +00:00
parent 7734d80e4d
commit 249933b899
2 changed files with 25 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: execvp.c,v 1.26 2005/11/29 03:11:59 christos Exp $ */
/* $NetBSD: execvp.c,v 1.27 2006/11/08 23:27:32 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: execvp.c,v 1.26 2005/11/29 03:11:59 christos Exp $");
__RCSID("$NetBSD: execvp.c,v 1.27 2006/11/08 23:27:32 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -127,12 +127,23 @@ retry: (void)execve(bp, argv, environ);
case ENOEXEC:
for (cnt = 0; argv[cnt] != NULL; ++cnt)
continue;
if ((memp = alloca((cnt + 2) * sizeof(*memp))) == NULL)
ln = (cnt + 2) * sizeof(*memp);
#if defined(__SSP__) || defined(__SSP_ALL__)
memp = malloc(ln);
#else
memp = alloca(ln);
#endif
if (memp == NULL)
goto done;
memp[0] = _PATH_BSHELL;
memp[1] = bp;
(void)memcpy(&memp[2], &argv[1], cnt * sizeof(*memp));
(void)execve(_PATH_BSHELL, __UNCONST(memp), environ);
#if defined(__SSP__) || defined(__SSP_ALL__)
eacces = errno;
free(memp);
errno = eacces;
#endif
goto done;
case ETXTBSY:
if (etxtbsy < 3)

View File

@ -1,4 +1,4 @@
/* $NetBSD: nlist_aout.c,v 1.15 2003/08/07 16:42:54 agc Exp $ */
/* $NetBSD: nlist_aout.c,v 1.16 2006/11/08 23:27:32 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@ -66,7 +66,7 @@
#if 0
static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: nlist_aout.c,v 1.15 2003/08/07 16:42:54 agc Exp $");
__RCSID("$NetBSD: nlist_aout.c,v 1.16 2006/11/08 23:27:32 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -149,7 +149,12 @@ __fdnlist_aout(fd, list)
}
if (lseek(fd, symoff, SEEK_SET) == -1)
return (-1);
if ((scoreboard = alloca((size_t)nent)) == NULL)
#if defined(__SSP__) || defined(__SSP_ALL__)
scoreboard = malloc((size_t)nent);
#else
scoreboard = alloca((size_t)nent);
#endif
if (scoreboard == NULL)
return (-1);
(void)memset(scoreboard, 0, (size_t)nent);
@ -179,6 +184,9 @@ __fdnlist_aout(fd, list)
}
}
munmap(strtab, strsize);
#if defined(__SSP__) || defined(__SSP_ALL__)
free(scoreboard);
#endif
return (nent);
}
#endif /* NLIST_AOUT */