summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/iked/util.c9
-rw-r--r--usr.sbin/httpd/httpd.c11
-rw-r--r--usr.sbin/ntpd/constraint.c9
-rw-r--r--usr.sbin/relayd/relayd.c11
4 files changed, 10 insertions, 30 deletions
diff --git a/sbin/iked/util.c b/sbin/iked/util.c
index 7b108de21e8..9363b19ca21 100644
--- a/sbin/iked/util.c
+++ b/sbin/iked/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.27 2015/08/21 11:59:28 reyk Exp $ */
+/* $OpenBSD: util.c,v 1.28 2015/11/19 21:32:53 mmcc Exp $ */
/*
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
@@ -636,17 +636,12 @@ char *
get_string(uint8_t *ptr, size_t len)
{
size_t i;
- char *str;
for (i = 0; i < len; i++)
if (!isprint(ptr[i]))
break;
- if ((str = calloc(1, i + 1)) == NULL)
- return (NULL);
- memcpy(str, ptr, i);
-
- return (str);
+ return strndup(ptr, i);
}
const char *
diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c
index dee51a23f07..9d463ee1c31 100644
--- a/usr.sbin/httpd/httpd.c
+++ b/usr.sbin/httpd/httpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.c,v 1.46 2015/11/05 18:00:43 florian Exp $ */
+/* $OpenBSD: httpd.c,v 1.47 2015/11/19 21:32:53 mmcc Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -831,18 +831,13 @@ char *
get_string(uint8_t *ptr, size_t len)
{
size_t i;
- char *str;
for (i = 0; i < len; i++)
if (!(isprint((unsigned char)ptr[i]) ||
isspace((unsigned char)ptr[i])))
break;
- if ((str = calloc(1, i + 1)) == NULL)
- return (NULL);
- memcpy(str, ptr, i);
-
- return (str);
+ return strndup(ptr, i);
}
void *
@@ -850,7 +845,7 @@ get_data(uint8_t *ptr, size_t len)
{
uint8_t *data;
- if ((data = calloc(1, len)) == NULL)
+ if ((data = malloc(len)) == NULL)
return (NULL);
memcpy(data, ptr, len);
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);
}
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c
index 9fac1207a1c..e1881b4010f 100644
--- a/usr.sbin/relayd/relayd.c
+++ b/usr.sbin/relayd/relayd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.c,v 1.144 2015/10/14 07:58:14 reyk Exp $ */
+/* $OpenBSD: relayd.c,v 1.145 2015/11/19 21:32:53 mmcc Exp $ */
/*
* Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -1494,18 +1494,13 @@ char *
get_string(u_int8_t *ptr, size_t len)
{
size_t i;
- char *str;
for (i = 0; i < len; i++)
if (!(isprint((unsigned char)ptr[i]) ||
isspace((unsigned char)ptr[i])))
break;
- if ((str = calloc(1, i + 1)) == NULL)
- return (NULL);
- memcpy(str, ptr, i);
-
- return (str);
+ return strndup(ptr, i);
}
void *
@@ -1513,7 +1508,7 @@ get_data(u_int8_t *ptr, size_t len)
{
u_int8_t *data;
- if ((data = calloc(1, len)) == NULL)
+ if ((data = malloc(len)) == NULL)
return (NULL);
memcpy(data, ptr, len);