bk: 5585f34aO_eFLi_BRej-iRjZwDH8kA
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.
#include <config.h>
-#include <string.h>
+#include <ntp_assert.h>
#include "ntp_malloc.h"
+#include <string.h>
#ifndef HAVE_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;