Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern replace strcpy with copystr and remove useless strc...



details:   https://anonhg.NetBSD.org/src/rev/acc71672d7b8
branches:  trunk
changeset: 325425:acc71672d7b8
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Dec 24 14:47:04 2013 +0000

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

diffstat:

 sys/kern/kern_exec.c |  13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diffs (42 lines):

diff -r 8267e11a763f -r acc71672d7b8 sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c      Tue Dec 24 13:57:06 2013 +0000
+++ b/sys/kern/kern_exec.c      Tue Dec 24 14:47:04 2013 +0000
@@ -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 @@
        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 @@
                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.



Home | Main Index | Thread Index | Old Index