From: Harlan Stenn Date: Sat, 20 Jun 2015 23:12:10 +0000 (+0000) Subject: [Bug 2854] Missing brace in libntp/strdup.c. Masanari Iida. X-Git-Tag: NTP_4_3_43~2^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43ec5431ddf7d3b713128f71a10a6b3bc5a80199;p=thirdparty%2Fntp.git [Bug 2854] Missing brace in libntp/strdup.c. Masanari Iida. bk: 5585f34aO_eFLi_BRej-iRjZwDH8kA --- diff --git a/ChangeLog b/ChangeLog index e96088e1b..ac3474807 100644 --- 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. diff --git a/libntp/strdup.c b/libntp/strdup.c index f7565a2fb..62d5a16d4 100644 --- a/libntp/strdup.c +++ b/libntp/strdup.c @@ -1,7 +1,8 @@ #include -#include +#include #include "ntp_malloc.h" +#include #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;