replace strcpy with copystr and remove useless strcpy (Maxime Villard)

This commit is contained in:
christos 2013-12-24 14:47:04 +00:00
parent e8b006b990
commit 54a8b0e862

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exec.c,v 1.367 2013/11/23 22:15:16 christos Exp $ */
/* $NetBSD: kern_exec.c,v 1.368 2013/12/24 14:47:04 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.367 2013/11/23 22:15:16 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.368 2013/12/24 14:47:04 christos Exp $");
#include "opt_exec.h"
#include "opt_execfmt.h"
@ -319,8 +319,9 @@ check_exec(struct lwp *l, struct exec_package *epp, struct pathbuf *pb)
if ((error = namei(&nd)) != 0)
return error;
epp->ep_vp = vp = nd.ni_vp;
/* this cannot overflow as both are size PATH_MAX */
strcpy(epp->ep_resolvedname, nd.ni_pnbuf);
/* normally this can't fail */
if ((error = copystr(nd.ni_pnbuf, epp->ep_resolvedname, PATH_MAX, NULL)))
goto bad1;
#ifdef DIAGNOSTIC
/* paranoia (take this out once namei stuff stabilizes) */
@ -640,11 +641,7 @@ execve_loadvm(struct lwp *l, const char *path, char * const *args,
goto clrflg;
}
data->ed_pathstring = pathbuf_stringcopy_get(data->ed_pathbuf);
data->ed_resolvedpathbuf = PNBUF_GET();
#ifdef DIAGNOSTIC
strcpy(data->ed_resolvedpathbuf, "/wrong");
#endif
/*
* initialize the fields of the exec package.