summaryrefslogtreecommitdiffstats
path: root/bin/date
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2006-08-20 06:31:24 +0000
committerimp <imp@FreeBSD.org>2006-08-20 06:31:24 +0000
commitf6de1709c1818a1f561cc0a93683fcdab75ff765 (patch)
treed714cfdef4d07c89c806d0fd7d9d54e34305225f /bin/date
parentb3096d26bc83d0a1762c006c973a8f813d2d124b (diff)
downloadFreeBSD-src-f6de1709c1818a1f561cc0a93683fcdab75ff765.zip
FreeBSD-src-f6de1709c1818a1f561cc0a93683fcdab75ff765.tar.gz
Use strlcpy in place of strncpy + setting the last character NUL. To
be safe, memset the entire msg to '0'.
Diffstat (limited to 'bin/date')
-rw-r--r--bin/date/netdate.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/bin/date/netdate.c b/bin/date/netdate.c
index 77e0788..b844106 100644
--- a/bin/date/netdate.c
+++ b/bin/date/netdate.c
@@ -108,14 +108,14 @@ netsettime(time_t tval)
warnx("all ports in use");
goto bad;
}
+ memset(&msg, 0, sizeof(msg));
msg.tsp_type = TSP_SETDATE;
msg.tsp_vers = TSPVERSION;
if (gethostname(hostname, sizeof(hostname))) {
warn("gethostname");
goto bad;
}
- (void)strncpy(msg.tsp_name, hostname, sizeof(msg.tsp_name) - 1);
- msg.tsp_name[sizeof(msg.tsp_name) - 1] = '\0';
+ (void)strlcpy(msg.tsp_name, hostname, sizeof(msg.tsp_name));
msg.tsp_seq = htons((u_short)0);
msg.tsp_time.tv_sec = htonl((u_long)tval);
msg.tsp_time.tv_usec = htonl((u_long)0);
OpenPOWER on IntegriCloud