summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2008-06-09 18:30:04 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2008-06-09 18:30:04 +0000
commit1f63821771a19f3ee519fc00a2fe496c8beacaab (patch)
treec168bdbe24e4260d7a133d7f79705846b6c19a64
parent8df5fc371b2dba96217fc28ba5760bab2b988c8e (diff)
do not copy up to two garbage characters from a 1 char string into a 4 char
output buffer; ok henning
-rw-r--r--usr.sbin/ntpd/sensors.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/ntpd/sensors.c b/usr.sbin/ntpd/sensors.c
index 8bbae220e20..c7d4f94b33e 100644
--- a/usr.sbin/ntpd/sensors.c
+++ b/usr.sbin/ntpd/sensors.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sensors.c,v 1.37 2008/06/09 16:52:04 deraadt Exp $ */
+/* $OpenBSD: sensors.c,v 1.38 2008/06/09 18:30:03 deraadt Exp $ */
/*
* Copyright (c) 2006 Henning Brauer <henning@openbsd.org>
@@ -129,8 +129,10 @@ sensor_add(int sensordev, char *dxname)
if (cs->refstr == NULL)
memcpy(&s->refstr, "HARD", sizeof(s->refstr));
- else
- memcpy(&s->refstr, cs->refstr, sizeof(s->refstr));
+ else {
+ s->refstr = 0;
+ strncpy((char *)&s->refstr, cs->refstr, sizeof(s->refstr));
+ }
TAILQ_INSERT_TAIL(&conf->ntp_sensors, s, entry);