Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/bootp use strlcpy/strlcat
details: https://anonhg.NetBSD.org/src/rev/0585b295c7f3
branches: trunk
changeset: 547385:0585b295c7f3
user: itojun <itojun%NetBSD.org@localhost>
date: Sat May 17 20:58:39 2003 +0000
description:
use strlcpy/strlcat
diffstat:
usr.sbin/bootp/bootpd/bootpd.c | 18 +++++++-----------
usr.sbin/bootp/bootptest/bootptest.c | 6 +++---
2 files changed, 10 insertions(+), 14 deletions(-)
diffs (83 lines):
diff -r 3a80f2207f1c -r 0585b295c7f3 usr.sbin/bootp/bootpd/bootpd.c
--- a/usr.sbin/bootp/bootpd/bootpd.c Sat May 17 20:55:44 2003 +0000
+++ b/usr.sbin/bootp/bootpd/bootpd.c Sat May 17 20:58:39 2003 +0000
@@ -22,7 +22,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: bootpd.c,v 1.17 2003/01/06 13:26:28 wiz Exp $");
+__RCSID("$NetBSD: bootpd.c,v 1.18 2003/05/17 20:58:39 itojun Exp $");
#endif
/*
@@ -307,7 +307,7 @@
"bootpd: missing hostname\n");
break;
}
- strncpy(hostname, stmp, sizeof(hostname)-1);
+ strlcpy(hostname, stmp, sizeof(hostname));
break;
case 'i': /* inetd mode */
@@ -815,8 +815,7 @@
* daemon chroot directory (i.e. /tftpboot).
*/
if (hp->flags.tftpdir) {
- strncpy(realpath, hp->tftpdir->string, sizeof(realpath) - 1);
- realpath[sizeof(realpath) - 1] = '\0';
+ strlcpy(realpath, hp->tftpdir->string, sizeof(realpath));
clntpath = &realpath[strlen(realpath)];
} else {
realpath[0] = '\0';
@@ -871,12 +870,9 @@
* Construct bootfile path.
*/
if (homedir) {
- if (homedir[0] != '/') {
- strncat(realpath, "/", sizeof(realpath) - 1);
- realpath[sizeof(realpath) - 1] = '\0';
- }
- strncat(realpath, homedir, sizeof(realpath) - 1);
- realpath[sizeof(realpath) - 1] = '\0';
+ if (homedir[0] != '/')
+ strlcat(realpath, "/", sizeof(realpath));
+ strlcat(realpath, homedir, sizeof(realpath));
homedir = NULL;
}
if (bootfile) {
@@ -929,7 +925,7 @@
#endif /* CHECK_FILE_ACCESS */
}
}
- strncpy(bp->bp_file, clntpath, BP_FILE_LEN);
+ strlcpy(bp->bp_file, clntpath, sizeof(bp->bp_file));
if (debug > 2)
report(LOG_INFO, "bootfile=\"%s\"", clntpath);
diff -r 3a80f2207f1c -r 0585b295c7f3 usr.sbin/bootp/bootptest/bootptest.c
--- a/usr.sbin/bootp/bootptest/bootptest.c Sat May 17 20:55:44 2003 +0000
+++ b/usr.sbin/bootp/bootptest/bootptest.c Sat May 17 20:58:39 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bootptest.c,v 1.11 2002/09/20 19:23:58 mycroft Exp $ */
+/* $NetBSD: bootptest.c,v 1.12 2003/05/17 20:58:40 itojun Exp $ */
/*
* bootptest.c - Test out a bootp server.
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: bootptest.c,v 1.11 2002/09/20 19:23:58 mycroft Exp $");
+__RCSID("$NetBSD: bootptest.c,v 1.12 2003/05/17 20:58:40 itojun Exp $");
#endif
char *usage = "bootptest [-h] server-name [vendor-data-template-file]";
@@ -298,7 +298,7 @@
xid = (int32) getpid();
bp->bp_xid = (u_int32) htonl(xid);
if (bp_file)
- strncpy(bp->bp_file, bp_file, BP_FILE_LEN);
+ strlcpy(bp->bp_file, bp_file, sizeof(bp->bp_file));
/*
* Fill in the hardware address (or client IP address)
Home |
Main Index |
Thread Index |
Old Index