aboutsummaryrefslogtreecommitdiffstats
path: root/libntp/strdup.c
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2015-07-01 03:12:13 +0000
committerCy Schubert <cy@FreeBSD.org>2015-07-01 03:12:13 +0000
commit873997f35a991eee09ed91148a0cf332360380da (patch)
tree5b1ffa3ad0e56e0e9f2991011729791ee86d7632 /libntp/strdup.c
parent4ba32eb5a8bf3455c09d1513ed2af8d2c861a6ba (diff)
downloadsrc-873997f35a991eee09ed91148a0cf332360380da.tar.gz
src-873997f35a991eee09ed91148a0cf332360380da.zip
Vendor import ntp-4.2.8p3.vendor/ntp/4.2.8p3
Approved by: delphij (implicit, using SO hat) Security: VuXML: 0d0f3050-1f69-11e5-9ba9-d050996490d0 Security: http://bugs.ntp.org/show_bug.cgi?id=2853 Security: https://www.kb.cert.org/vuls/id/668167 Security: http://support.ntp.org/bin/view/Main/SecurityNotice#June_2015_NTP_Security_Vulnerabi
Notes
Notes: svn path=/vendor/ntp/dist/; revision=284990 svn path=/vendor/ntp/4.2.8p3/; revision=284992; tag=vendor/ntp/4.2.8p3
Diffstat (limited to 'libntp/strdup.c')
-rw-r--r--libntp/strdup.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/libntp/strdup.c b/libntp/strdup.c
index f7565a2fb8f7..62d5a16d433c 100644
--- a/libntp/strdup.c
+++ b/libntp/strdup.c
@@ -1,7 +1,8 @@
#include <config.h>
-#include <string.h>
+#include <ntp_assert.h>
#include "ntp_malloc.h"
+#include <string.h>
#ifndef HAVE_STRDUP
@@ -15,15 +16,13 @@ strdup(
size_t octets;
char * cp;
- if (s) {
- octets = 1 + strlen(s);
- cp = malloc(octets);
- if (NULL != cp)
- memcpy(cp, s, octets);
- else
- cp = NULL;
+ REQUIRE(s);
+ octets = strlen(s) + 1;
+ if ((cp = malloc(octets)) == NULL)
+ return NULL;
+ memcpy(cp, s, octets);
- return(cp);
+ return cp;
}
#else
int strdup_c_nonempty_compilation_unit;