]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2854] Missing brace in libntp/strdup.c. Masanari Iida.
authorHarlan Stenn <stenn@ntp.org>
Sat, 20 Jun 2015 23:12:10 +0000 (23:12 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sat, 20 Jun 2015 23:12:10 +0000 (23:12 +0000)
bk: 5585f34aO_eFLi_BRej-iRjZwDH8kA

ChangeLog
libntp/strdup.c

index e96088e1b014ca4e97b544205e1583ab7da0f4b3..ac3474807a937b2e394fe9e6b48b7518b86e5234 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,7 @@
    Fixed compiler warnings about numeric range overflow
    (The original topic was fixed in a byplay to bug#2830)
 * [Bug 2845] Harden memory allocation in ntpd.
+* [Bug 2854] Missing brace in libntp/strdup.c.  Masanari Iida.
 * Report select() debug messages at debug level 3 now.
 * sntp/scripts/genLocInfo: treat raspbian as debian.
 * Unity test framework fixes.
index f7565a2fb8f75a960042bfb6509dc874a8fbb7d7..62d5a16d433c611b5bf9cce27857bf40d77a88b0 100644 (file)
@@ -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;