Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern calcargs: Correct the size of "argc" in the stack s...
details: https://anonhg.NetBSD.org/src/rev/b781bb3b2fd4
branches: trunk
changeset: 328796:b781bb3b2fd4
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Fri Apr 18 06:59:32 2014 +0000
description:
calcargs: Correct the size of "argc" in the stack size calculation.
(The old code has worked because it is compensated by wrong size calculation
of "auxinfo" (multiplied by sizeof(void *)).)
diffstat:
sys/kern/kern_exec.c | 17 +++++++----------
1 files changed, 7 insertions(+), 10 deletions(-)
diffs (53 lines):
diff -r 669d4af053c3 -r b781bb3b2fd4 sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c Fri Apr 18 06:53:13 2014 +0000
+++ b/sys/kern/kern_exec.c Fri Apr 18 06:59:32 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_exec.c,v 1.401 2014/04/16 02:22:38 uebayasi Exp $ */
+/* $NetBSD: kern_exec.c,v 1.402 2014/04/18 06:59:32 uebayasi Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.401 2014/04/16 02:22:38 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.402 2014/04/18 06:59:32 uebayasi Exp $");
#include "opt_exec.h"
#include "opt_execfmt.h"
@@ -1331,6 +1331,7 @@
struct exec_package * const epp = &data->ed_pack;
const size_t nargenvptrs =
+ 1 + /* long argc */
data->ed_argc + /* char *argv[] */
1 + /* \0 */
data->ed_envc + /* char *env[] */
@@ -1340,11 +1341,7 @@
const size_t ptrsz = (epp->ep_flags & EXEC_32) ?
sizeof(int) : sizeof(char *);
- const size_t argenvlen =
- sizeof(int) + /* XXX argc in stack is long, not int */
- (nargenvptrs * ptrsz); /* XXX auxinfo multiplied by ptr size? */
-
- return argenvlen + argenvstrlen;
+ return (nargenvptrs * ptrsz) + argenvstrlen;
}
static size_t
@@ -1584,10 +1581,10 @@
CTASSERT(sizeof(*cpp) == sizeof(argc));
dp = (char *)(cpp +
- 1 + /* argc */
- argc + /* *argv[] */
+ 1 + /* long argc */
+ argc + /* char *argv[] */
1 + /* \0 */
- envc + /* *env[] */
+ envc + /* char *env[] */
1 + /* \0 */
/* XXX auxinfo multiplied by ptr size? */
pack->ep_esch->es_arglen); /* auxinfo */
Home |
Main Index |
Thread Index |
Old Index