Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/rpc.lockd use strlcpy instead of strncpy.



details:   https://anonhg.NetBSD.org/src/rev/21e7e2b8c065
branches:  trunk
changeset: 544203:21e7e2b8c065
user:      yamt <yamt%NetBSD.org@localhost>
date:      Fri Mar 14 14:08:44 2003 +0000

description:
use strlcpy instead of strncpy.

diffstat:

 usr.sbin/rpc.lockd/lockd_lock.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r ddf7b818b2d9 -r 21e7e2b8c065 usr.sbin/rpc.lockd/lockd_lock.c
--- a/usr.sbin/rpc.lockd/lockd_lock.c   Fri Mar 14 14:03:00 2003 +0000
+++ b/usr.sbin/rpc.lockd/lockd_lock.c   Fri Mar 14 14:08:44 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lockd_lock.c,v 1.14 2003/03/14 14:03:00 yamt Exp $     */
+/*     $NetBSD: lockd_lock.c,v 1.15 2003/03/14 14:08:44 yamt Exp $     */
 
 /*
  * Copyright (c) 2000 Manuel Bouyer.
@@ -90,7 +90,7 @@
 /* struct describing a lock */
 struct host {
        LIST_ENTRY(host) hostlst;
-       char name[SM_MAXSTRLEN];
+       char name[SM_MAXSTRLEN+1];
        int refcnt;
 };
 
@@ -191,7 +191,8 @@
        }
        memcpy(newfl->client_cookie.n_bytes, lckarg->cookie.n_bytes,
            lckarg->cookie.n_len);
-       strncpy(newfl->client_name, lckarg->alock.caller_name, 128);
+       strlcpy(newfl->client_name, lckarg->alock.caller_name,
+           sizeof(newfl->client_name);
        newfl->nsm_status = lckarg->state;
        newfl->status = 0;
        newfl->flags = flags;
@@ -686,7 +687,7 @@
        }
        /* not found, have to create an entry for it */
        hp = malloc(sizeof(struct host));
-       strncpy(hp->name, hostname, SM_MAXSTRLEN);
+       strlcpy(hp->name, hostname, sizeof(hp->name));
        hp->refcnt = 1;
        syslog(LOG_DEBUG, "monitoring host %s",
            hostname);



Home | Main Index | Thread Index | Old Index