Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/net use strlcpy where appropriate
details: https://anonhg.NetBSD.org/src/rev/24b287f1b2aa
branches: trunk
changeset: 534738:24b287f1b2aa
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Aug 02 07:50:35 2002 +0000
description:
use strlcpy where appropriate
diffstat:
lib/libc/net/res_init.c | 16 +++++++---------
lib/libc/net/res_query.c | 8 ++++----
2 files changed, 11 insertions(+), 13 deletions(-)
diffs (87 lines):
diff -r 6e8f7b2dc4c1 -r 24b287f1b2aa lib/libc/net/res_init.c
--- a/lib/libc/net/res_init.c Fri Aug 02 07:12:51 2002 +0000
+++ b/lib/libc/net/res_init.c Fri Aug 02 07:50:35 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: res_init.c,v 1.38 2002/06/27 10:22:11 itojun Exp $ */
+/* $NetBSD: res_init.c,v 1.39 2002/08/02 07:50:35 itojun Exp $ */
/*-
* Copyright (c) 1985, 1989, 1993
@@ -59,7 +59,7 @@
static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
static char rcsid[] = "Id: res_init.c,v 8.8 1997/06/01 20:34:37 vixie Exp ";
#else
-__RCSID("$NetBSD: res_init.c,v 1.38 2002/06/27 10:22:11 itojun Exp $");
+__RCSID("$NetBSD: res_init.c,v 1.39 2002/08/02 07:50:35 itojun Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -202,8 +202,7 @@
/* Allow user to override the local domain definition */
if ((cp = getenv("LOCALDOMAIN")) != NULL) {
- (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
- _res.defdname[sizeof(_res.defdname) - 1] = '\0';
+ (void)strlcpy(_res.defdname, cp, sizeof(_res.defdname));
if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL)
*cp = '\0';
haveenv++;
@@ -257,8 +256,7 @@
cp++;
if ((*cp == '\0') || (*cp == '\n'))
continue;
- (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
- _res.defdname[sizeof(_res.defdname) - 1] = '\0';
+ (void)strlcpy(_res.defdname, cp, sizeof(_res.defdname));
if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL)
*cp = '\0';
havesearch = 0;
@@ -276,8 +274,7 @@
cp++;
if ((*cp == '\0') || (*cp == '\n'))
continue;
- (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
- _res.defdname[sizeof(_res.defdname) - 1] = '\0';
+ (void)strlcpy(_res.defdname, cp, sizeof(_res.defdname));
if ((cp = strchr(_res.defdname, '\n')) != NULL)
*cp = '\0';
/*
@@ -471,7 +468,8 @@
rv = gethostname(buf, sizeof(_res.defdname));
_res.defdname[sizeof(_res.defdname) - 1] = '\0';
if (rv == 0 && (cp = strchr(buf, '.')))
- (void)strncpy(_res.defdname, cp + 1, sizeof(_res.defdname) - 1);
+ (void)strlcpy(_res.defdname, cp + 1,
+ sizeof(_res.defdname));
}
/* find components of local domain that might be searched */
diff -r 6e8f7b2dc4c1 -r 24b287f1b2aa lib/libc/net/res_query.c
--- a/lib/libc/net/res_query.c Fri Aug 02 07:12:51 2002 +0000
+++ b/lib/libc/net/res_query.c Fri Aug 02 07:50:35 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: res_query.c,v 1.33 2002/06/27 10:22:12 itojun Exp $ */
+/* $NetBSD: res_query.c,v 1.34 2002/08/02 07:50:35 itojun Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -59,7 +59,7 @@
static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "Id: res_query.c,v 8.10 1997/06/01 20:34:37 vixie Exp ";
#else
-__RCSID("$NetBSD: res_query.c,v 1.33 2002/06/27 10:22:12 itojun Exp $");
+__RCSID("$NetBSD: res_query.c,v 1.34 2002/08/02 07:50:35 itojun Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -431,8 +431,8 @@
for (cp2 = cp1 + 1; *cp2 && !isspace((u_char) *cp2);
++cp2)
;
- abuf[sizeof(abuf) - 1] = *cp2 = '\0';
- (void)strncpy(abuf, cp1, sizeof(abuf) - 1);
+ *cp2 = '\0';
+ (void)strlcpy(abuf, cp1, sizeof(abuf));
(void)fclose(fp);
return (abuf);
}
Home |
Main Index |
Thread Index |
Old Index