767173cec2
Update 4.2.8p14 --> 4.2.8p15 Summary: Systems that use a CMAC algorithm in ntp.keys will not release a bit of memory on each packet that uses a CMAC keyid, eventually causing ntpd to run out of memory and fail. The CMAC cleanup from https://bugs.ntp.org/3447, part of ntp-4.2.8p11, introduced a bug whereby the CMAC data structure was no longer completely removed. MFC after: 3 days Security: NTP Bug 3661
56 lines
854 B
C
56 lines
854 B
C
#include <config.h>
|
|
|
|
#include <ntp_assert.h>
|
|
#include <string.h>
|
|
#include "ntp_malloc.h"
|
|
#include "l_stdlib.h"
|
|
|
|
#define STRDUP_EMPTY_UNIT
|
|
|
|
#ifndef HAVE_STRDUP
|
|
# undef STRDUP_EMPTY_UNIT
|
|
char *strdup(const char *s);
|
|
char *
|
|
strdup(
|
|
const char *s
|
|
)
|
|
{
|
|
size_t octets;
|
|
char * cp;
|
|
|
|
REQUIRE(s);
|
|
octets = strlen(s) + 1;
|
|
if ((cp = malloc(octets)) == NULL)
|
|
return NULL;
|
|
memcpy(cp, s, octets);
|
|
|
|
return cp;
|
|
}
|
|
#endif
|
|
|
|
#ifndef HAVE_MEMCHR
|
|
# undef STRDUP_EMPTY_UNIT
|
|
void *memchr(const void *s, int c, size_t n)
|
|
{
|
|
const unsigned char *p = s;
|
|
while (n && *p != c) {
|
|
--n;
|
|
++p;
|
|
}
|
|
return n ? (char*)p : NULL;
|
|
}
|
|
#endif
|
|
|
|
#ifndef HAVE_STRNLEN
|
|
# undef STRDUP_EMPTY_UNIT
|
|
size_t strnlen(const char *s, size_t n)
|
|
{
|
|
const char *e = memchr(s, 0, n);
|
|
return e ? (size_t)(e - s) : n;
|
|
}
|
|
#endif
|
|
|
|
#ifdef STRDUP_EMPTY_UNIT
|
|
int strdup_c_nonempty_compilation_unit;
|
|
#endif
|