summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd
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/httpd
parentc99db105bf0d8e1dcf7449664582b6fc7cb28173 (diff)
Simplify all instances of get_string() and get_data() using malloc() and
strndup(). ok millert@
Diffstat (limited to 'usr.sbin/httpd')
-rw-r--r--usr.sbin/httpd/httpd.c11
1 files changed, 3 insertions, 8 deletions
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);