summaryrefslogtreecommitdiff
path: root/sys/kern/kern_exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r--sys/kern/kern_exec.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 3fb29047c5a..801b69df0d4 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exec.c,v 1.105 2007/12/11 22:09:29 kettenis Exp $ */
+/* $OpenBSD: kern_exec.c,v 1.106 2008/02/13 19:31:22 kettenis Exp $ */
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
/*-
@@ -388,6 +388,9 @@ sys_execve(struct proc *p, void *v, register_t *retval)
sgap = STACKGAPLEN;
if (stackgap_random != 0)
sgap += (arc4random() * ALIGNBYTES) & (stackgap_random - 1);
+#ifdef MACHINE_STACK_GROWS_UP
+ sgap = ALIGN(sgap);
+#endif
/* Now check if args & environ fit into new stack */
len = ((argc + envc + 2 + pack.ep_emul->e_arglen) * sizeof(char *) +
sizeof(long) + dp + sgap + sizeof(struct ps_strings)) - argp;
@@ -435,8 +438,8 @@ sys_execve(struct proc *p, void *v, register_t *retval)
arginfo.ps_nenvstr = envc;
#ifdef MACHINE_STACK_GROWS_UP
- stack = (char *)USRSTACK + sizeof(arginfo) + ALIGN(sgap);
- slen = len - sizeof(arginfo) - ALIGN(sgap);
+ stack = (char *)USRSTACK + sizeof(arginfo) + sgap;
+ slen = len - sizeof(arginfo) - sgap;
#else
stack = (char *)(USRSTACK - len);
#endif