Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/rsh use strlcpy



details:   https://anonhg.NetBSD.org/src/rev/b7f9b7e88f58
branches:  trunk
changeset: 547201:b7f9b7e88f58
user:      itojun <itojun%NetBSD.org@localhost>
date:      Thu May 15 00:47:48 2003 +0000

description:
use strlcpy

diffstat:

 usr.bin/rsh/rsh.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r 9e27ba7d7a41 -r b7f9b7e88f58 usr.bin/rsh/rsh.c
--- a/usr.bin/rsh/rsh.c Thu May 15 00:23:54 2003 +0000
+++ b/usr.bin/rsh/rsh.c Thu May 15 00:47:48 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rsh.c,v 1.17 2003/04/07 01:46:41 hubertf Exp $ */
+/*     $NetBSD: rsh.c,v 1.18 2003/05/15 00:47:48 itojun Exp $  */
 
 /*-
  * Copyright (c) 1983, 1990, 1993, 1994
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)rsh.c      8.4 (Berkeley) 4/29/95";
 #else
-__RCSID("$NetBSD: rsh.c,v 1.17 2003/04/07 01:46:41 hubertf Exp $");
+__RCSID("$NetBSD: rsh.c,v 1.18 2003/05/15 00:47:48 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -571,15 +571,16 @@
 copyargs(char **argv)
 {
        int cc;
-       char **ap, *args, *p;
+       char **ap, *args, *p, *ep;
 
        cc = 0;
        for (ap = argv; *ap; ++ap)
                cc += strlen(*ap) + 1;
        if (!(args = malloc((u_int)cc)))
                err(1, "malloc");
+       ep = args + cc;
        for (p = args, *p = '\0', ap = argv; *ap; ++ap) {
-               (void)strcpy(p, *ap);
+               (void)strlcpy(p, *ap, ep - p);
                p += strlen(p);
                if (ap[1])
                        *p++ = ' ';



Home | Main Index | Thread Index | Old Index