Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern - preserve the error number returned from copyin.
details: https://anonhg.NetBSD.org/src/rev/14ee9e6edeef
branches: trunk
changeset: 340548:14ee9e6edeef
user: christos <christos%NetBSD.org@localhost>
date: Sat Sep 12 17:04:57 2015 +0000
description:
- preserve the error number returned from copyin.
- preserve the original pathname in ep_kname, because this is what gets passed
to userland in exec_script.c
diffstat:
sys/kern/kern_exec.c | 33 +++++++++++++++++++--------------
1 files changed, 19 insertions(+), 14 deletions(-)
diffs (96 lines):
diff -r e8d71fc5aa47 -r 14ee9e6edeef sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c Sat Sep 12 15:25:01 2015 +0000
+++ b/sys/kern/kern_exec.c Sat Sep 12 17:04:57 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_exec.c,v 1.414 2015/09/11 01:23:37 christos Exp $ */
+/* $NetBSD: kern_exec.c,v 1.415 2015/09/12 17:04:57 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.414 2015/09/11 01:23:37 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.415 2015/09/12 17:04:57 christos Exp $");
#include "opt_exec.h"
#include "opt_execfmt.h"
@@ -593,11 +593,12 @@
#endif
}
-static struct pathbuf *
-makepathbuf(struct lwp *l, const char *upath)
+static int
+makepathbuf(struct lwp *l, const char *upath, struct pathbuf **pbp,
+ size_t *offs)
{
char *path, *bp;
- size_t len;
+ size_t len, tlen;
int error;
struct cwdinfo *cwdi;
@@ -606,11 +607,13 @@
if (error) {
PNBUF_PUT(path);
DPRINTF(("%s: copyin path @%p %d\n", __func__, upath, error));
- return NULL;
+ return error;
}
- if (path[0] == '/')
+ if (path[0] == '/') {
+ *offs = 0;
goto out;
+ }
len++;
if (len + 1 >= MAXPATHLEN)
@@ -630,12 +633,14 @@
error));
goto out;
}
- len = path + MAXPATHLEN - bp;
+ tlen = path + MAXPATHLEN - bp;
- memmove(path, bp, len);
- path[len] = '\0';
+ memmove(path, bp, tlen);
+ path[tlen] = '\0';
+ *offs = tlen - len;
out:
- return pathbuf_assimilate(path);
+ *pbp = pathbuf_assimilate(path);
+ return 0;
}
static int
@@ -648,6 +653,7 @@
struct proc *p;
char *dp;
u_int modgen;
+ size_t offs;
KASSERT(data != NULL);
@@ -697,8 +703,7 @@
* functions call check_exec() recursively - for example,
* see exec_script_makecmds().
*/
- data->ed_pathbuf = makepathbuf(l, path);
- if (data->ed_pathbuf == NULL)
+ if ((error = makepathbuf(l, path, &data->ed_pathbuf, &offs)) != 0)
goto clrflg;
data->ed_pathstring = pathbuf_stringcopy_get(data->ed_pathbuf);
data->ed_resolvedpathbuf = PNBUF_GET();
@@ -706,7 +711,7 @@
/*
* initialize the fields of the exec package.
*/
- epp->ep_kname = data->ed_pathstring;
+ epp->ep_kname = data->ed_pathstring + offs;
epp->ep_resolvedname = data->ed_resolvedpathbuf;
epp->ep_hdr = kmem_alloc(exec_maxhdrsz, KM_SLEEP);
epp->ep_hdrlen = exec_maxhdrsz;
Home |
Main Index |
Thread Index |
Old Index