From 2aa9d1c9dd8fe6a21ef55ac92c224c9b3d9701ad Mon Sep 17 00:00:00 2001 From: jrf Date: Tue, 7 Sep 2004 13:20:39 +0000 Subject: Replaced strncpy with strlcpy. Thanks to Peter Postma who pointed them our in PR #25762. Approved by christos@NetBSD.org. --- atc/log.c | 7 +++---- sail/dr_1.c | 8 +++----- sail/sync.c | 14 ++++++-------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/atc/log.c b/atc/log.c index 5f5d9bfe..a92aaae5 100644 --- a/atc/log.c +++ b/atc/log.c @@ -1,4 +1,4 @@ -/* $NetBSD: log.c,v 1.12 2003/08/07 09:36:54 agc Exp $ */ +/* $NetBSD: log.c,v 1.13 2004/09/07 13:20:39 jrf Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -46,7 +46,7 @@ #if 0 static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: log.c,v 1.12 2003/08/07 09:36:54 agc Exp $"); +__RCSID("$NetBSD: log.c,v 1.13 2004/09/07 13:20:39 jrf Exp $"); #endif #endif /* not lint */ @@ -180,8 +180,7 @@ log_score(list_em) } strcpy(thisscore.name, pw->pw_name); uname(&name); - strncpy(thisscore.host, name.nodename, sizeof(thisscore.host)-1); - thisscore.host[sizeof(thisscore.host) - 1] = '\0'; + strlcpy(thisscore.host, name.nodename, sizeof(thisscore.host)); cp = strrchr(file, '/'); if (cp == NULL) { diff --git a/sail/dr_1.c b/sail/dr_1.c index 6610af4b..1d8b5444 100644 --- a/sail/dr_1.c +++ b/sail/dr_1.c @@ -1,4 +1,4 @@ -/* $NetBSD: dr_1.c,v 1.19 2003/08/07 09:37:41 agc Exp $ */ +/* $NetBSD: dr_1.c,v 1.20 2004/09/07 13:20:39 jrf Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dr_1.c,v 1.19 2003/08/07 09:37:41 agc Exp $"); +__RCSID("$NetBSD: dr_1.c,v 1.20 2004/09/07 13:20:39 jrf Exp $"); #endif #endif /* not lint */ @@ -429,10 +429,8 @@ next(void) *tp = toupper(*tp); p = tp; } - strncpy(bestship->file->captain, p, + strlcpy(bestship->file->captain, p, sizeof bestship->file->captain); - bestship->file->captain - [sizeof bestship->file->captain - 1] = 0; logger(bestship); } return -1; diff --git a/sail/sync.c b/sail/sync.c index d9532ebb..7fe76604 100644 --- a/sail/sync.c +++ b/sail/sync.c @@ -1,4 +1,4 @@ -/* $NetBSD: sync.c,v 1.22 2004/01/27 20:27:59 jsm Exp $ */ +/* $NetBSD: sync.c,v 1.23 2004/09/07 13:20:39 jrf Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)sync.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: sync.c,v 1.22 2004/01/27 20:27:59 jsm Exp $"); +__RCSID("$NetBSD: sync.c,v 1.23 2004/09/07 13:20:39 jrf Exp $"); #endif #endif /* not lint */ @@ -379,9 +379,8 @@ sync_update(int type, struct ship *ship, const char *astr, long a, long b, long break; } case W_CAPTAIN: - strncpy(ship->file->captain, astr, - sizeof ship->file->captain - 1); - ship->file->captain[sizeof ship->file->captain - 1] = 0; + strlcpy(ship->file->captain, astr, + sizeof ship->file->captain); break; case W_CAPTURED: if (a < 0) @@ -418,9 +417,8 @@ sync_update(int type, struct ship *ship, const char *astr, long a, long b, long ship->specs->hull = a; break; case W_MOVE: - strncpy(ship->file->movebuf, astr, - sizeof ship->file->movebuf - 1); - ship->file->movebuf[sizeof ship->file->movebuf - 1] = 0; + strlcpy(ship->file->movebuf, astr, + sizeof ship->file->movebuf); break; case W_PCREW: ship->file->pcrew = a; -- cgit v1.2.3-56-ge451