Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern PR/49287: David Holland: Skip the right number of b...
details: https://anonhg.NetBSD.org/src/rev/ee7632f35afb
branches: trunk
changeset: 333243:ee7632f35afb
user: christos <christos%NetBSD.org@localhost>
date: Fri Oct 24 21:13:30 2014 +0000
description:
PR/49287: David Holland: Skip the right number of bytes to go over the first
argument in the argv vector. Fixes netbsd32 script execution, where you lost
the first argument because it skipped 8 bytes instead of 4.
diffstat:
sys/kern/kern_exec.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diffs (52 lines):
diff -r d1f746b7d313 -r ee7632f35afb sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c Fri Oct 24 21:08:36 2014 +0000
+++ b/sys/kern/kern_exec.c Fri Oct 24 21:13:30 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_exec.c,v 1.408 2014/06/22 17:23:34 maxv Exp $ */
+/* $NetBSD: kern_exec.c,v 1.409 2014/10/24 21:13:30 christos 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.408 2014/06/22 17:23:34 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.409 2014/10/24 21:13:30 christos Exp $");
#include "opt_exec.h"
#include "opt_execfmt.h"
@@ -1336,6 +1336,12 @@
}
static size_t
+ptrsz(const struct exec_package *epp)
+{
+ return (epp->ep_flags & EXEC_32) ? sizeof(int) : sizeof(char *);
+}
+
+static size_t
calcargs(struct execve_data * restrict data, const size_t argenvstrlen)
{
struct exec_package * const epp = &data->ed_pack;
@@ -1348,10 +1354,7 @@
1 + /* \0 */
epp->ep_esch->es_arglen; /* auxinfo */
- const size_t ptrsz = (epp->ep_flags & EXEC_32) ?
- sizeof(int) : sizeof(char *);
-
- return (nargenvptrs * ptrsz) + argenvstrlen;
+ return (nargenvptrs * ptrsz(epp)) + argenvstrlen;
}
static size_t
@@ -1506,7 +1509,7 @@
return EINVAL;
}
if (epp->ep_flags & EXEC_SKIPARG)
- args++;
+ args = (const void *)((const char *)args + ptrsz(epp));
i = 0;
error = copyinargstrs(data, args, fetch_element, &dp, &i, ktr_execarg);
if (error != 0) {
Home |
Main Index |
Thread Index |
Old Index