summaryrefslogtreecommitdiff
path: root/usr.sbin/ntpd
diff options
context:
space:
mode:
authormmcc <mmcc@cvs.openbsd.org>2015-11-19 21:32:54 +0000
committermmcc <mmcc@cvs.openbsd.org>2015-11-19 21:32:54 +0000
commit6add882f0b5301a7618cec704a729d25f559c7c8 (patch)
tree43808c5e8a49fac845d2f06e0614b7e5a796ec85 /usr.sbin/ntpd
parentc99db105bf0d8e1dcf7449664582b6fc7cb28173 (diff)
Simplify all instances of get_string() and get_data() using malloc() and
strndup(). ok millert@
Diffstat (limited to 'usr.sbin/ntpd')
-rw-r--r--usr.sbin/ntpd/constraint.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/usr.sbin/ntpd/constraint.c b/usr.sbin/ntpd/constraint.c
index 30bdda0f3c9..c2a01e8bf08 100644
--- a/usr.sbin/ntpd/constraint.c
+++ b/usr.sbin/ntpd/constraint.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: constraint.c,v 1.20 2015/11/17 15:34:36 deraadt Exp $ */
+/* $OpenBSD: constraint.c,v 1.21 2015/11/19 21:32:53 mmcc Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -979,15 +979,10 @@ char *
get_string(u_int8_t *ptr, size_t len)
{
size_t i;
- char *str;
for (i = 0; i < len; i++)
if (!(isprint(ptr[i]) || isspace(ptr[i])))
break;
- if ((str = calloc(1, i + 1)) == NULL)
- return (NULL);
- memcpy(str, ptr, i);
-
- return (str);
+ return strndup(ptr, i);
}