diff options
| author | itojun <itojun@NetBSD.org> | 2003-07-12 13:23:55 +0000 |
|---|---|---|
| committer | itojun <itojun@NetBSD.org> | 2003-07-12 13:23:55 +0000 |
| commit | 032ed69f9a47a49c09dd24ffb4e5dfa09cd030b8 (patch) | |
| tree | 7a1ccda107e800453dafc3f5041e5ada3118f8af /usr.bin | |
| parent | a7f5ddbf6454871154c3109480b03fd50760ff2d (diff) | |
strlcpy
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/finger/util.c | 9 | ||||
| -rw-r--r-- | usr.bin/ftp/fetch.c | 9 | ||||
| -rw-r--r-- | usr.bin/ipcs/ipcs.c | 9 | ||||
| -rw-r--r-- | usr.bin/telnet/authenc.c | 6 | ||||
| -rw-r--r-- | usr.bin/telnet/commands.c | 20 | ||||
| -rw-r--r-- | usr.bin/telnet/main.c | 6 |
6 files changed, 26 insertions, 33 deletions
diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c index bbde43b2746..4e151cfad06 100644 --- a/usr.bin/finger/util.c +++ b/usr.bin/finger/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.19 2003/01/20 05:30:11 simonb Exp $ */ +/* $NetBSD: util.c,v 1.20 2003/07/12 13:28:10 itojun Exp $ */ /* * Copyright (c) 1989, 1993 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: util.c,v 1.19 2003/01/20 05:30:11 simonb Exp $"); +__RCSID("$NetBSD: util.c,v 1.20 2003/07/12 13:28:10 itojun Exp $"); #endif #endif /* not lint */ @@ -82,7 +82,7 @@ match(pw, user) if (!strcasecmp(pw->pw_name, user)) return(1); - (void)strncpy(bp = tbuf, pw->pw_gecos, sizeof(tbuf)); + (void)strlcpy(bp = tbuf, pw->pw_gecos, sizeof(tbuf)); /* Ampersands get replaced by the login name. */ if (!(p = strsep(&bp, ","))) @@ -365,8 +365,7 @@ userinfo(pn, pw) pn->dir = strdup(pw->pw_dir); pn->shell = strdup(pw->pw_shell); - (void)strncpy(bp = tbuf, pw->pw_gecos, sizeof(tbuf)); - tbuf[sizeof(tbuf) - 1] = '\0'; + (void)strlcpy(bp = tbuf, pw->pw_gecos, sizeof(tbuf)); /* ampersands get replaced by the login name */ if (!(p = strsep(&bp, ","))) diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index acd1edc8df6..3d56a3bee8f 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.141 2003/05/14 14:31:00 wiz Exp $ */ +/* $NetBSD: fetch.c,v 1.142 2003/07/12 13:30:04 itojun Exp $ */ /*- * Copyright (c) 1997-2003 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.141 2003/05/14 14:31:00 wiz Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.142 2003/07/12 13:30:04 itojun Exp $"); #endif /* not lint */ /* @@ -665,9 +665,8 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) */ ai_unmapped(res); if (getnameinfo(res->ai_addr, res->ai_addrlen, - hbuf, sizeof(hbuf), NULL, 0, - NI_NUMERICHOST) != 0) - strncpy(hbuf, "invalid", sizeof(hbuf)); + hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) != 0) + strlcpy(hbuf, "invalid", sizeof(hbuf)); if (verbose && res != res0) fprintf(ttyout, "Trying %s...\n", hbuf); diff --git a/usr.bin/ipcs/ipcs.c b/usr.bin/ipcs/ipcs.c index 5092c6704c3..69f83df6aa0 100644 --- a/usr.bin/ipcs/ipcs.c +++ b/usr.bin/ipcs/ipcs.c @@ -1,4 +1,4 @@ -/* $NetBSD: ipcs.c,v 1.29 2003/04/07 01:42:37 simonb Exp $ */ +/* $NetBSD: ipcs.c,v 1.30 2003/07/12 13:29:15 itojun Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -133,10 +133,9 @@ cvt_time(time_t t, char *buf, size_t buflen) { struct tm *tm; - if (t == 0) { - (void)strncpy(buf, "no-entry", buflen - 1); - buf[buflen - 1] = '\0'; - } else { + if (t == 0) + (void)strlcpy(buf, "no-entry", buflen); + else { tm = localtime(&t); (void)snprintf(buf, buflen, "%2d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec); diff --git a/usr.bin/telnet/authenc.c b/usr.bin/telnet/authenc.c index 1345ab085f9..fe849a313b8 100644 --- a/usr.bin/telnet/authenc.c +++ b/usr.bin/telnet/authenc.c @@ -1,4 +1,4 @@ -/* $NetBSD: authenc.c,v 1.10 2003/06/18 20:51:00 christos Exp $ */ +/* $NetBSD: authenc.c,v 1.11 2003/07/12 13:33:08 itojun Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)authenc.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: authenc.c,v 1.10 2003/06/18 20:51:00 christos Exp $"); +__RCSID("$NetBSD: authenc.c,v 1.11 2003/07/12 13:33:08 itojun Exp $"); #endif #endif /* not lint */ @@ -102,7 +102,7 @@ telnet_gets(char *prompt, char *result, int length, int echo) printf("%s", prompt); res = fgets(result, length, stdin); } else if ((res = getpass(prompt)) != NULL) { - strncpy(result, res, length); + strlcpy(result, res, length); res = result; } TerminalNewMode(om); diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index 66a74f69a0c..d7227d253a2 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $NetBSD: commands.c,v 1.51 2003/06/18 20:51:00 christos Exp $ */ +/* $NetBSD: commands.c,v 1.52 2003/07/12 13:33:08 itojun Exp $ */ /* * Copyright (C) 1997 and 1998 WIDE Project. @@ -67,7 +67,7 @@ #if 0 static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95"; #else -__RCSID("$NetBSD: commands.c,v 1.51 2003/06/18 20:51:00 christos Exp $"); +__RCSID("$NetBSD: commands.c,v 1.52 2003/07/12 13:33:08 itojun Exp $"); #endif #endif /* not lint */ @@ -2343,10 +2343,8 @@ tn(int argc, char *argv[]) getnameinfo(res0->ai_addr, res0->ai_addrlen, _hostname, sizeof(_hostname), NULL, 0, NI_NAMEREQD) == 0) ; /* okay */ - else { - strncpy(_hostname, hostname, sizeof(_hostname) - 1); - _hostname[sizeof(_hostname) - 1] = '\0'; - } + else + strlcpy(_hostname, hostname, sizeof(_hostname)); } else { /* FQDN - try again with forward DNS lookup */ memset(&hints, 0, sizeof(hints)); @@ -2362,12 +2360,10 @@ tn(int argc, char *argv[]) fprintf(stderr, "%s: %s\n", hostname, gai_strerror(error)); return 0; } - if (res0->ai_canonname) { - (void) strncpy(_hostname, res0->ai_canonname, - sizeof(_hostname) - 1); - } else - (void) strncpy(_hostname, hostname, sizeof(_hostname) - 1); - _hostname[sizeof(_hostname) - 1] = '\0'; + if (res0->ai_canonname) + (void)strlcpy(_hostname, res0->ai_canonname, sizeof(_hostname)); + else + (void)strlcpy(_hostname, hostname, sizeof(_hostname)); } hostname = _hostname; diff --git a/usr.bin/telnet/main.c b/usr.bin/telnet/main.c index 1ac015b26cd..23b105c1f94 100644 --- a/usr.bin/telnet/main.c +++ b/usr.bin/telnet/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.18 2003/06/18 20:51:00 christos Exp $ */ +/* $NetBSD: main.c,v 1.19 2003/07/12 13:33:08 itojun Exp $ */ /* * Copyright (c) 1988, 1990, 1993 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1990, 1993\n\ #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95"; #else -__RCSID("$NetBSD: main.c,v 1.18 2003/06/18 20:51:00 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.19 2003/07/12 13:33:08 itojun Exp $"); #endif #endif /* not lint */ @@ -264,7 +264,7 @@ main(int argc, char *argv[]) { extern char *dest_realm, dst_realm_buf[], dst_realm_sz; dest_realm = dst_realm_buf; - (void)strncpy(dest_realm, optarg, dst_realm_sz); + (void)strlcpy(dest_realm, optarg, dst_realm_sz); } #else fprintf(stderr, |
