summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/sntp
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2016-01-22 15:55:21 +0000
committerdelphij <delphij@FreeBSD.org>2016-01-22 15:55:21 +0000
commit0e1dba9a0aa72f6f27001a50552a8c67575da336 (patch)
treedbb1c1e8cb8058b52ef547a1f18b9751613aeb04 /contrib/ntp/sntp
parent7a67cba86b1ced9982ebb0dd11a9a987829efe9e (diff)
downloadFreeBSD-src-0e1dba9a0aa72f6f27001a50552a8c67575da336.zip
FreeBSD-src-0e1dba9a0aa72f6f27001a50552a8c67575da336.tar.gz
MFC r294554: MFV r294491: ntp 4.2.8p6.
Security: CVE-2015-7973, CVE-2015-7974, CVE-2015-7975 Security: CVE-2015-7976, CVE-2015-7977, CVE-2015-7978 Security: CVE-2015-7979, CVE-2015-8138, CVE-2015-8139 Security: CVE-2015-8140, CVE-2015-8158 With hat: so
Diffstat (limited to 'contrib/ntp/sntp')
-rwxr-xr-xcontrib/ntp/sntp/configure20
-rw-r--r--contrib/ntp/sntp/crypto.c25
-rw-r--r--contrib/ntp/sntp/crypto.h20
-rw-r--r--contrib/ntp/sntp/include/copyright.def2
-rw-r--r--contrib/ntp/sntp/include/version.def2
-rw-r--r--contrib/ntp/sntp/include/version.texi6
-rw-r--r--contrib/ntp/sntp/invoke-sntp.texi4
-rw-r--r--contrib/ntp/sntp/libopts/configfile.c44
-rw-r--r--contrib/ntp/sntp/libopts/enum.c10
-rw-r--r--contrib/ntp/sntp/libopts/find.c2
-rw-r--r--contrib/ntp/sntp/libopts/init.c5
-rw-r--r--contrib/ntp/sntp/libopts/load.c2
-rw-r--r--contrib/ntp/sntp/libopts/makeshell.c6
-rw-r--r--contrib/ntp/sntp/libopts/nested.c4
-rw-r--r--contrib/ntp/sntp/libopts/parse-duration.c10
-rw-r--r--contrib/ntp/sntp/libopts/reset.c2
-rw-r--r--contrib/ntp/sntp/libopts/save.c4
-rw-r--r--contrib/ntp/sntp/libopts/tokenize.c2
-rw-r--r--contrib/ntp/sntp/m4/version.m42
-rw-r--r--contrib/ntp/sntp/main.c2
-rw-r--r--contrib/ntp/sntp/networking.c2
-rw-r--r--contrib/ntp/sntp/sntp-opts.c20
-rw-r--r--contrib/ntp/sntp/sntp-opts.h8
-rw-r--r--contrib/ntp/sntp/sntp.1sntpman8
-rw-r--r--contrib/ntp/sntp/sntp.1sntpmdoc6
-rw-r--r--contrib/ntp/sntp/sntp.html4
-rw-r--r--contrib/ntp/sntp/sntp.man.in8
-rw-r--r--contrib/ntp/sntp/sntp.mdoc.in6
-rw-r--r--contrib/ntp/sntp/tests/crypto.c68
-rw-r--r--contrib/ntp/sntp/tests/fileHandlingTest.c65
-rw-r--r--contrib/ntp/sntp/tests/fileHandlingTest.h.in21
-rw-r--r--contrib/ntp/sntp/tests/keyFile.c112
-rw-r--r--contrib/ntp/sntp/tests/packetHandling.c141
-rw-r--r--contrib/ntp/sntp/tests/packetProcessing.c214
-rw-r--r--contrib/ntp/sntp/tests/run-packetProcessing.c36
-rw-r--r--contrib/ntp/sntp/unity/unity_internals.h2
-rw-r--r--contrib/ntp/sntp/version.c2
37 files changed, 500 insertions, 397 deletions
diff --git a/contrib/ntp/sntp/configure b/contrib/ntp/sntp/configure
index ce397ef..b4ce6de 100755
--- a/contrib/ntp/sntp/configure
+++ b/contrib/ntp/sntp/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for sntp 4.2.8p5.
+# Generated by GNU Autoconf 2.69 for sntp 4.2.8p6.
#
# Report bugs to <http://bugs.ntp.org./>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='sntp'
PACKAGE_TARNAME='sntp'
-PACKAGE_VERSION='4.2.8p5'
-PACKAGE_STRING='sntp 4.2.8p5'
+PACKAGE_VERSION='4.2.8p6'
+PACKAGE_STRING='sntp 4.2.8p6'
PACKAGE_BUGREPORT='http://bugs.ntp.org./'
PACKAGE_URL='http://www.ntp.org./'
@@ -1491,7 +1491,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures sntp 4.2.8p5 to adapt to many kinds of systems.
+\`configure' configures sntp 4.2.8p6 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1561,7 +1561,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of sntp 4.2.8p5:";;
+ short | recursive ) echo "Configuration of sntp 4.2.8p6:";;
esac
cat <<\_ACEOF
@@ -1706,7 +1706,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-sntp configure 4.2.8p5
+sntp configure 4.2.8p6
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2536,7 +2536,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by sntp $as_me 4.2.8p5, which was
+It was created by sntp $as_me 4.2.8p6, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3533,7 +3533,7 @@ fi
# Define the identity of the package.
PACKAGE='sntp'
- VERSION='4.2.8p5'
+ VERSION='4.2.8p6'
cat >>confdefs.h <<_ACEOF
@@ -31110,7 +31110,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by sntp $as_me 4.2.8p5, which was
+This file was extended by sntp $as_me 4.2.8p6, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -31177,7 +31177,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-sntp config.status 4.2.8p5
+sntp config.status 4.2.8p6
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/contrib/ntp/sntp/crypto.c b/contrib/ntp/sntp/crypto.c
index b178f8c..234e137 100644
--- a/contrib/ntp/sntp/crypto.c
+++ b/contrib/ntp/sntp/crypto.c
@@ -7,11 +7,11 @@ size_t key_cnt = 0;
int
make_mac(
- char *pkt_data,
+ const void *pkt_data,
int pkt_size,
int mac_size,
- struct key *cmp_key,
- char * digest
+ const struct key *cmp_key,
+ void * digest
)
{
u_int len = mac_size;
@@ -26,39 +26,40 @@ make_mac(
INIT_SSL();
key_type = keytype_from_text(cmp_key->type, NULL);
EVP_DigestInit(&ctx, EVP_get_digestbynid(key_type));
- EVP_DigestUpdate(&ctx, (u_char *)cmp_key->key_seq, (u_int)cmp_key->key_len);
- EVP_DigestUpdate(&ctx, (u_char *)pkt_data, (u_int)pkt_size);
- EVP_DigestFinal(&ctx, (u_char *)digest, &len);
+ EVP_DigestUpdate(&ctx, (const u_char *)cmp_key->key_seq, (u_int)cmp_key->key_len);
+ EVP_DigestUpdate(&ctx, pkt_data, (u_int)pkt_size);
+ EVP_DigestFinal(&ctx, digest, &len);
return (int)len;
}
-/* Generates a md5 digest of the key specified in keyid concatinated with the
+/* Generates a md5 digest of the key specified in keyid concatenated with the
* ntp packet (exluding the MAC) and compares this digest to the digest in
* the packet's MAC. If they're equal this function returns 1 (packet is
* authentic) or else 0 (not authentic).
*/
int
auth_md5(
- char *pkt_data,
+ const void *pkt_data,
int pkt_size,
int mac_size,
- struct key *cmp_key
+ const struct key *cmp_key
)
{
int hash_len;
int authentic;
char digest[20];
-
+ const u_char *pkt_ptr;
if (mac_size > (int)sizeof(digest))
return 0;
- hash_len = make_mac(pkt_data, pkt_size, sizeof(digest), cmp_key,
+ pkt_ptr = pkt_data;
+ hash_len = make_mac(pkt_ptr, pkt_size, sizeof(digest), cmp_key,
digest);
if (!hash_len)
authentic = FALSE;
else
- authentic = !memcmp(digest, pkt_data + pkt_size + 4,
+ authentic = !memcmp(digest, pkt_ptr + pkt_size + 4,
hash_len);
return authentic;
}
diff --git a/contrib/ntp/sntp/crypto.h b/contrib/ntp/sntp/crypto.h
index 39e0e6b..19cdbc4 100644
--- a/contrib/ntp/sntp/crypto.h
+++ b/contrib/ntp/sntp/crypto.h
@@ -17,16 +17,18 @@
/* #include "sntp-opts.h" */
struct key {
- struct key *next;
- int key_id;
- int key_len;
- char type[10];
- char key_seq[64];
+ struct key * next;
+ int key_id;
+ int key_len;
+ char type[10];
+ char key_seq[64];
};
-int auth_init(const char *keyfile, struct key **keys);
-void get_key(int key_id, struct key **d_key);
-int make_mac(char *pkt_data, int pkt_size, int mac_size, struct key *cmp_key, char *digest);
-int auth_md5(char *pkt_data, int pkt_size, int mac_size, struct key *cmp_key);
+extern int auth_init(const char *keyfile, struct key **keys);
+extern void get_key(int key_id, struct key **d_key);
+extern int make_mac(const void *pkt_data, int pkt_size, int mac_size,
+ const struct key *cmp_key, void *digest);
+extern int auth_md5(const void *pkt_data, int pkt_size, int mac_size,
+ const struct key *cmp_key);
#endif
diff --git a/contrib/ntp/sntp/include/copyright.def b/contrib/ntp/sntp/include/copyright.def
index 1cc7ad2..4fb4461 100644
--- a/contrib/ntp/sntp/include/copyright.def
+++ b/contrib/ntp/sntp/include/copyright.def
@@ -1,7 +1,7 @@
/* -*- Mode: Text -*- */
copyright = {
- date = "1992-2015";
+ date = "1992-2016";
owner = "The University of Delaware and Network Time Foundation";
eaddr = "http://bugs.ntp.org, bugs@ntp.org";
type = ntp;
diff --git a/contrib/ntp/sntp/include/version.def b/contrib/ntp/sntp/include/version.def
index ddc02d4..5a08174 100644
--- a/contrib/ntp/sntp/include/version.def
+++ b/contrib/ntp/sntp/include/version.def
@@ -1 +1 @@
-version = '4.2.8p5';
+version = '4.2.8p6';
diff --git a/contrib/ntp/sntp/include/version.texi b/contrib/ntp/sntp/include/version.texi
index 28b9357..fa9aeb3 100644
--- a/contrib/ntp/sntp/include/version.texi
+++ b/contrib/ntp/sntp/include/version.texi
@@ -1,3 +1,3 @@
-@set UPDATED 07 January 2016
-@set EDITION 4.2.8p5
-@set VERSION 4.2.8p5
+@set UPDATED 20 January 2016
+@set EDITION 4.2.8p6
+@set VERSION 4.2.8p6
diff --git a/contrib/ntp/sntp/invoke-sntp.texi b/contrib/ntp/sntp/invoke-sntp.texi
index 6ca3b06..695c9eb 100644
--- a/contrib/ntp/sntp/invoke-sntp.texi
+++ b/contrib/ntp/sntp/invoke-sntp.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-sntp.texi)
#
-# It has been AutoGen-ed January 7, 2016 at 11:23:24 PM by AutoGen 5.18.5
+# It has been AutoGen-ed January 20, 2016 at 04:06:42 AM by AutoGen 5.18.5
# From the definitions sntp-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -101,7 +101,7 @@ with a status code of 0.
@exampleindent 0
@example
-sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p5
+sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p6
Usage: sntp [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \
[ hostname-or-IP ...]
Flg Arg Option-Name Description
diff --git a/contrib/ntp/sntp/libopts/configfile.c b/contrib/ntp/sntp/libopts/configfile.c
index 03156ca..8244371e 100644
--- a/contrib/ntp/sntp/libopts/configfile.c
+++ b/contrib/ntp/sntp/libopts/configfile.c
@@ -182,9 +182,9 @@ optionFindValue(const tOptDesc * odesc, char const * name, char const * val)
}
else do {
- tArgList * argl = odesc->optCookie;
- int argct = argl->useCt;
- void ** poptv = (void **)(argl->apzArgs);
+ tArgList * argl = odesc->optCookie;
+ int argct = argl->useCt;
+ const void ** poptv = VOIDP(argl->apzArgs);
if (argct == 0) {
errno = ENOENT;
@@ -192,7 +192,7 @@ optionFindValue(const tOptDesc * odesc, char const * name, char const * val)
}
if (name == NULL) {
- res = (tOptionValue *)*poptv;
+ res = (const tOptionValue *)*poptv;
break;
}
@@ -249,7 +249,7 @@ optionFindNextValue(const tOptDesc * odesc, const tOptionValue * pPrevVal,
char const * pzName, char const * pzVal)
{
bool old_found = false;
- tOptionValue * res = NULL;
+ const tOptionValue * res = NULL;
(void)pzName;
(void)pzVal;
@@ -264,12 +264,12 @@ optionFindNextValue(const tOptDesc * odesc, const tOptionValue * pPrevVal,
}
else do {
- tArgList * argl = odesc->optCookie;
- int ct = argl->useCt;
- void ** poptv = (void **)argl->apzArgs;
+ tArgList * argl = odesc->optCookie;
+ int ct = argl->useCt;
+ const void ** poptv = VOIDP(argl->apzArgs);
while (--ct >= 0) {
- tOptionValue * pOV = *(poptv++);
+ const tOptionValue * pOV = *(poptv++);
if (old_found) {
res = pOV;
break;
@@ -315,8 +315,8 @@ optionFindNextValue(const tOptDesc * odesc, const tOptionValue * pPrevVal,
tOptionValue const *
optionGetValue(tOptionValue const * oov, char const * vname)
{
- tArgList * arg_list;
- tOptionValue * res = NULL;
+ tArgList * arg_list;
+ const tOptionValue * res = NULL;
if ((oov == NULL) || (oov->valType != OPARG_TYPE_HIERARCHY)) {
errno = EINVAL;
@@ -325,14 +325,14 @@ optionGetValue(tOptionValue const * oov, char const * vname)
arg_list = oov->v.nestVal;
if (arg_list->useCt > 0) {
- int ct = arg_list->useCt;
- void ** ovlist = (void **)(arg_list->apzArgs);
+ int ct = arg_list->useCt;
+ const void ** ovlist = VOIDP(arg_list->apzArgs);
if (vname == NULL) {
- res = (tOptionValue *)*ovlist;
+ res = (const tOptionValue *)*ovlist;
} else do {
- tOptionValue * opt_val = *(ovlist++);
+ const tOptionValue * opt_val = *(ovlist++);
if (strcmp(opt_val->pzName, vname) == 0) {
res = opt_val;
break;
@@ -374,9 +374,9 @@ optionGetValue(tOptionValue const * oov, char const * vname)
tOptionValue const *
optionNextValue(tOptionValue const * ov_list,tOptionValue const * oov )
{
- tArgList * arg_list;
- tOptionValue * res = NULL;
- int err = EINVAL;
+ tArgList * arg_list;
+ const tOptionValue * res = NULL;
+ int err = EINVAL;
if ((ov_list == NULL) || (ov_list->valType != OPARG_TYPE_HIERARCHY)) {
errno = EINVAL;
@@ -384,18 +384,18 @@ optionNextValue(tOptionValue const * ov_list,tOptionValue const * oov )
}
arg_list = ov_list->v.nestVal;
{
- int ct = arg_list->useCt;
- void ** o_list = (void **)(arg_list->apzArgs);
+ int ct = arg_list->useCt;
+ const void ** o_list = VOIDP(arg_list->apzArgs);
while (ct-- > 0) {
- tOptionValue * nov = *(o_list++);
+ const tOptionValue * nov = *(o_list++);
if (nov == oov) {
if (ct == 0) {
err = ENOENT;
} else {
err = 0;
- res = (tOptionValue *)*o_list;
+ res = (const tOptionValue *)*o_list;
}
break;
}
diff --git a/contrib/ntp/sntp/libopts/enum.c b/contrib/ntp/sntp/libopts/enum.c
index 3345558..e9bba83 100644
--- a/contrib/ntp/sntp/libopts/enum.c
+++ b/contrib/ntp/sntp/libopts/enum.c
@@ -189,12 +189,12 @@ find_name(char const * name, tOptions * pOpts, tOptDesc * pOD,
* The result gets stashed in a char * pointer.
*/
uintptr_t res = name_ct;
- size_t len = strlen((char *)name);
+ size_t len = strlen(name);
uintptr_t idx;
if (IS_DEC_DIGIT_CHAR(*name)) {
- char * pz = VOIDP(name);
- unsigned long val = strtoul(pz, &pz, 0);
+ char * pz;
+ unsigned long val = strtoul(name, &pz, 0);
if ((*pz == NUL) && (val < name_ct))
return (uintptr_t)val;
pz_enum_err_fmt = znum_too_large;
@@ -215,7 +215,7 @@ find_name(char const * name, tOptions * pOpts, tOptDesc * pOD,
* Multiple partial matches means we have an ambiguous match.
*/
for (idx = 0; idx < name_ct; idx++) {
- if (strncmp((char *)paz_names[idx], (char *)name, len) == 0) {
+ if (strncmp(paz_names[idx], name, len) == 0) {
if (paz_names[idx][len] == NUL)
return idx; /* full match */
@@ -500,7 +500,7 @@ find_member_bit(tOptions * opts, tOptDesc * od, char const * pz, int len,
if (shift_ct >= nm_ct)
return 0UL;
- return 1UL << shift_ct;
+ return (uintptr_t)1U << shift_ct;
}
}
diff --git a/contrib/ntp/sntp/libopts/find.c b/contrib/ntp/sntp/libopts/find.c
index 90591cc..97a24df 100644
--- a/contrib/ntp/sntp/libopts/find.c
+++ b/contrib/ntp/sntp/libopts/find.c
@@ -80,7 +80,7 @@ parse_opt(char const ** nm_pp, char ** arg_pp, char * buf, size_t bufsz)
buf[res] = NUL;
*nm_pp = buf;
- *arg_pp = (char *)p;
+ *arg_pp = VOIDP(p);
return res;
default:
diff --git a/contrib/ntp/sntp/libopts/init.c b/contrib/ntp/sntp/libopts/init.c
index e02e1e1..81d4eee 100644
--- a/contrib/ntp/sntp/libopts/init.c
+++ b/contrib/ntp/sntp/libopts/init.c
@@ -97,15 +97,14 @@ validate_struct(tOptions * opts, char const * pname)
*/
if (opts->pzProgName == NULL) {
char const * pz = strrchr(pname, DIRCH);
- char const ** pp =
- (char const **)(void **)&(opts->pzProgName);
+ char const ** pp = VOIDP(&(opts->pzProgName));
if (pz != NULL)
*pp = pz+1;
else
*pp = pname;
- pz = pathfind(getenv("PATH"), (char *)pname, "rx");
+ pz = pathfind(getenv("PATH"), pname, "rx");
if (pz != NULL)
pname = VOIDP(pz);
diff --git a/contrib/ntp/sntp/libopts/load.c b/contrib/ntp/sntp/libopts/load.c
index b5230af..ccda5b4 100644
--- a/contrib/ntp/sntp/libopts/load.c
+++ b/contrib/ntp/sntp/libopts/load.c
@@ -225,7 +225,7 @@ add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path)
if (strchr(prg_path, DIRCH) != NULL)
path = prg_path;
else {
- path = pathfind(getenv("PATH"), (char *)prg_path, "rx");
+ path = pathfind(getenv("PATH"), prg_path, "rx");
if (path == NULL)
return false;
diff --git a/contrib/ntp/sntp/libopts/makeshell.c b/contrib/ntp/sntp/libopts/makeshell.c
index a61df42..fbe8e17 100644
--- a/contrib/ntp/sntp/libopts/makeshell.c
+++ b/contrib/ntp/sntp/libopts/makeshell.c
@@ -401,7 +401,7 @@ emit_usage(tOptions * opts)
/* Copy the program name into the time/name buffer */
for (;;) {
- if ((*pzPN++ = (char)tolower(*pz++)) == NUL)
+ if ((*pzPN++ = (char)tolower((unsigned char)*pz++)) == NUL)
break;
}
@@ -671,8 +671,8 @@ emit_match_expr(char const * name, tOptDesc * cod, tOptions * opts)
continue;
match_ct = 0;
- while ( toupper(od->pz_DisableName[match_ct])
- == toupper(name[match_ct]))
+ while ( toupper((unsigned char)od->pz_DisableName[match_ct])
+ == toupper((unsigned char)name[match_ct]))
match_ct++;
if (match_ct > min_match_ct)
min_match_ct = match_ct;
diff --git a/contrib/ntp/sntp/libopts/nested.c b/contrib/ntp/sntp/libopts/nested.c
index f4fb226..aaf089f 100644
--- a/contrib/ntp/sntp/libopts/nested.c
+++ b/contrib/ntp/sntp/libopts/nested.c
@@ -859,6 +859,7 @@ LOCAL int
get_special_char(char const ** ppz, int * ct)
{
char const * pz = *ppz;
+ char * rz;
if (*ct < 3)
return '&';
@@ -872,7 +873,8 @@ get_special_char(char const ** ppz, int * ct)
base = 16;
pz++;
}
- retch = (int)strtoul(pz, (char **)&pz, base);
+ retch = (int)strtoul(pz, &rz, base);
+ pz = rz;
if (*pz != ';')
return '&';
base = (int)(++pz - *ppz);
diff --git a/contrib/ntp/sntp/libopts/parse-duration.c b/contrib/ntp/sntp/libopts/parse-duration.c
index e072b7d..11e3d828 100644
--- a/contrib/ntp/sntp/libopts/parse-duration.c
+++ b/contrib/ntp/sntp/libopts/parse-duration.c
@@ -60,14 +60,20 @@ typedef enum {
static unsigned long
str_const_to_ul (cch_t * str, cch_t ** ppz, int base)
{
- return strtoul (str, (char **)ppz, base);
+ char * pz;
+ int rv = strtoul (str, &pz, base);
+ *ppz = pz;
+ return rv;
}
/* Wrapper around strtol that does not require a cast. */
static long
str_const_to_l (cch_t * str, cch_t ** ppz, int base)
{
- return strtol (str, (char **)ppz, base);
+ char * pz;
+ int rv = strtol (str, &pz, base);
+ *ppz = pz;
+ return rv;
}
/* Returns BASE + VAL * SCALE, interpreting BASE = BAD_TIME
diff --git a/contrib/ntp/sntp/libopts/reset.c b/contrib/ntp/sntp/libopts/reset.c
index 6ca2c05..97ecb52 100644
--- a/contrib/ntp/sntp/libopts/reset.c
+++ b/contrib/ntp/sntp/libopts/reset.c
@@ -113,7 +113,7 @@ optionResetOpt(tOptions * pOpts, tOptDesc * pOD)
assert(0 == 1);
}
} else {
- succ = opt_find_long(pOpts, (char *)pzArg, &opt_state);
+ succ = opt_find_long(pOpts, pzArg, &opt_state);
if (! SUCCESSFUL(succ)) {
fprintf(stderr, zIllOptStr, pOpts->pzProgPath, pzArg);
pOpts->pUsageProc(pOpts, EXIT_FAILURE);
diff --git a/contrib/ntp/sntp/libopts/save.c b/contrib/ntp/sntp/libopts/save.c
index f462ced..cdab05f 100644
--- a/contrib/ntp/sntp/libopts/save.c
+++ b/contrib/ntp/sntp/libopts/save.c
@@ -453,7 +453,7 @@ prt_val_list(FILE * fp, char const * name, tArgList * al)
if (al == NULL)
return;
opt_ct = al->useCt;
- opt_list = (void **)al->apzArgs;
+ opt_list = VOIDP(al->apzArgs);
if (opt_ct <= 0) {
fprintf(fp, OPEN_CLOSE_FMT, name);
@@ -488,7 +488,7 @@ prt_nested(FILE * fp, tOptDesc * p)
return;
opt_ct = al->useCt;
- opt_list = (void **)al->apzArgs;
+ opt_list = VOIDP(al->apzArgs);
if (opt_ct <= 0)
return;
diff --git a/contrib/ntp/sntp/libopts/tokenize.c b/contrib/ntp/sntp/libopts/tokenize.c
index cbff7fb..25550ea 100644
--- a/contrib/ntp/sntp/libopts/tokenize.c
+++ b/contrib/ntp/sntp/libopts/tokenize.c
@@ -57,7 +57,7 @@ copy_cooked(ch_t ** ppDest, char const ** ppSrc)
case NUL: *ppSrc = NULL; return;
case '"': goto done;
case '\\':
- pSrc += ao_string_cook_escape_char((char *)pSrc, (char *)&ch, 0x7F);
+ pSrc += ao_string_cook_escape_char((const char *)pSrc, (char *)&ch, 0x7F);
if (ch == 0x7F)
break;
/* FALLTHROUGH */
diff --git a/contrib/ntp/sntp/m4/version.m4 b/contrib/ntp/sntp/m4/version.m4
index b8f98b5..236cc18 100644
--- a/contrib/ntp/sntp/m4/version.m4
+++ b/contrib/ntp/sntp/m4/version.m4
@@ -1 +1 @@
-m4_define([VERSION_NUMBER],[4.2.8p5])
+m4_define([VERSION_NUMBER],[4.2.8p6])
diff --git a/contrib/ntp/sntp/main.c b/contrib/ntp/sntp/main.c
index 870db93..78ed7c2 100644
--- a/contrib/ntp/sntp/main.c
+++ b/contrib/ntp/sntp/main.c
@@ -1135,7 +1135,7 @@ generate_pkt (
if (pkt_key != NULL) {
x_pkt->exten[0] = htonl(key_id);
mac_size = 20; /* max room for MAC */
- mac_size = make_mac((char *)x_pkt, pkt_len, mac_size,
+ mac_size = make_mac(x_pkt, pkt_len, mac_size,
pkt_key, (char *)&x_pkt->exten[1]);
if (mac_size > 0)
pkt_len += mac_size + 4;
diff --git a/contrib/ntp/sntp/networking.c b/contrib/ntp/sntp/networking.c
index 6a176c5..21cf09a 100644
--- a/contrib/ntp/sntp/networking.c
+++ b/contrib/ntp/sntp/networking.c
@@ -184,7 +184,7 @@ process_pkt (
** keyfile and compare those md5sums.
*/
mac_size = exten_len << 2;
- if (!auth_md5((char *)rpkt, pkt_len - mac_size,
+ if (!auth_md5(rpkt, pkt_len - mac_size,
mac_size - 4, pkt_key)) {
is_authentic = FALSE;
break;
diff --git a/contrib/ntp/sntp/sntp-opts.c b/contrib/ntp/sntp/sntp-opts.c
index 69fb786..d11f0b2 100644
--- a/contrib/ntp/sntp/sntp-opts.c
+++ b/contrib/ntp/sntp/sntp-opts.c
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (sntp-opts.c)
*
- * It has been AutoGen-ed January 7, 2016 at 11:22:49 PM by AutoGen 5.18.5
+ * It has been AutoGen-ed January 20, 2016 at 04:06:07 AM by AutoGen 5.18.5
* From the definitions sntp-opts.def
* and the template file options
*
@@ -18,7 +18,7 @@
* The sntp program is copyrighted and licensed
* under the following terms:
*
- * Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.
+ * Copyright (C) 1992-2016 The University of Delaware and Network Time Foundation, all rights reserved.
* This is free software. It is licensed for use, modification and
* redistribution under the terms of the NTP License, copies of which
* can be seen at:
@@ -70,8 +70,8 @@ extern FILE * option_usage_fp;
* static const strings for sntp options
*/
static char const sntp_opt_strs[2549] =
-/* 0 */ "sntp 4.2.8p5\n"
- "Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n"
+/* 0 */ "sntp 4.2.8p6\n"
+ "Copyright (C) 1992-2016 The University of Delaware and Network Time Foundation, all rights reserved.\n"
"This is free software. It is licensed for use, modification and\n"
"redistribution under the terms of the NTP License, copies of which\n"
"can be seen at:\n"
@@ -155,7 +155,7 @@ static char const sntp_opt_strs[2549] =
/* 2298 */ "LOAD_OPTS\0"
/* 2308 */ "no-load-opts\0"
/* 2321 */ "SNTP\0"
-/* 2326 */ "sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p5\n"
+/* 2326 */ "sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p6\n"
"Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n"
"\t\t[ hostname-or-IP ...]\n\0"
/* 2485 */ "$HOME\0"
@@ -163,7 +163,7 @@ static char const sntp_opt_strs[2549] =
/* 2493 */ ".ntprc\0"
/* 2500 */ "http://bugs.ntp.org, bugs@ntp.org\0"
/* 2534 */ "\n\0"
-/* 2536 */ "sntp 4.2.8p5";
+/* 2536 */ "sntp 4.2.8p6";
/**
* ipv4 option description with
@@ -1173,8 +1173,8 @@ static void bogus_function(void) {
translate option names.
*/
/* referenced via sntpOptions.pzCopyright */
- puts(_("sntp 4.2.8p5\n\
-Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\
+ puts(_("sntp 4.2.8p6\n\
+Copyright (C) 1992-2016 The University of Delaware and Network Time Foundation, all rights reserved.\n\
This is free software. It is licensed for use, modification and\n\
redistribution under the terms of the NTP License, copies of which\n\
can be seen at:\n"));
@@ -1263,7 +1263,7 @@ implied warranty.\n"));
puts(_("load options from a config file"));
/* referenced via sntpOptions.pzUsageTitle */
- puts(_("sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p5\n\
+ puts(_("sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p6\n\
Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
\t\t[ hostname-or-IP ...]\n"));
@@ -1271,7 +1271,7 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
puts(_("\n"));
/* referenced via sntpOptions.pzFullVersion */
- puts(_("sntp 4.2.8p5"));
+ puts(_("sntp 4.2.8p6"));
/* referenced via sntpOptions.pzFullUsage */
puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/sntp/sntp-opts.h b/contrib/ntp/sntp/sntp-opts.h
index 78951ab..ab741c7 100644
--- a/contrib/ntp/sntp/sntp-opts.h
+++ b/contrib/ntp/sntp/sntp-opts.h
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (sntp-opts.h)
*
- * It has been AutoGen-ed January 7, 2016 at 11:22:48 PM by AutoGen 5.18.5
+ * It has been AutoGen-ed January 20, 2016 at 04:06:06 AM by AutoGen 5.18.5
* From the definitions sntp-opts.def
* and the template file options
*
@@ -18,7 +18,7 @@
* The sntp program is copyrighted and licensed
* under the following terms:
*
- * Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.
+ * Copyright (C) 1992-2016 The University of Delaware and Network Time Foundation, all rights reserved.
* This is free software. It is licensed for use, modification and
* redistribution under the terms of the NTP License, copies of which
* can be seen at:
@@ -91,9 +91,9 @@ typedef enum {
/** count of all options for sntp */
#define OPTION_CT 23
/** sntp version */
-#define SNTP_VERSION "4.2.8p5"
+#define SNTP_VERSION "4.2.8p6"
/** Full sntp version text */
-#define SNTP_FULL_VERSION "sntp 4.2.8p5"
+#define SNTP_FULL_VERSION "sntp 4.2.8p6"
/**
* Interface defines for all options. Replace "n" with the UPPER_CASED
diff --git a/contrib/ntp/sntp/sntp.1sntpman b/contrib/ntp/sntp/sntp.1sntpman
index 792fc52..0a83bd3 100644
--- a/contrib/ntp/sntp/sntp.1sntpman
+++ b/contrib/ntp/sntp/sntp.1sntpman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH sntp 1sntpman "07 Jan 2016" "4.2.8p5" "User Commands"
+.TH sntp 1sntpman "20 Jan 2016" "4.2.8p6" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-e.aO3S/ag-r.aG2S)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-vxaitn/ag-Ixaasn)
.\"
-.\" It has been AutoGen-ed January 7, 2016 at 11:23:20 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed January 20, 2016 at 04:06:38 AM by AutoGen 5.18.5
.\" From the definitions sntp-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
@@ -348,7 +348,7 @@ it to autogen-users@lists.sourceforge.net. Thank you.
.NOP "Dave Hart"
.br
.SH "COPYRIGHT"
-Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2016 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH "BUGS"
Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/sntp/sntp.1sntpmdoc b/contrib/ntp/sntp/sntp.1sntpmdoc
index 8005e9a..86b72ad 100644
--- a/contrib/ntp/sntp/sntp.1sntpmdoc
+++ b/contrib/ntp/sntp/sntp.1sntpmdoc
@@ -1,9 +1,9 @@
-.Dd January 7 2016
+.Dd January 20 2016
.Dt SNTP 1sntpmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (sntp-opts.mdoc)
.\"
-.\" It has been AutoGen-ed January 7, 2016 at 11:23:27 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed January 20, 2016 at 04:06:45 AM by AutoGen 5.18.5
.\" From the definitions sntp-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@@ -303,7 +303,7 @@ it to autogen\-users@lists.sourceforge.net. Thank you.
.An "Harlan Stenn"
.An "Dave Hart"
.Sh "COPYRIGHT"
-Copyright (C) 1992\-2015 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2016 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh "BUGS"
Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/sntp/sntp.html b/contrib/ntp/sntp/sntp.html
index 6aa66fb..61efd50 100644
--- a/contrib/ntp/sntp/sntp.html
+++ b/contrib/ntp/sntp/sntp.html
@@ -36,7 +36,7 @@ display the time offset of the system clock relative to the server
clock. Run as root, it can correct the system clock to this offset as
well. It can be run as an interactive command or from a cron job.
- <p>This document applies to version 4.2.8p5 of <code>sntp</code>.
+ <p>This document applies to version 4.2.8p6 of <code>sntp</code>.
<p>The program implements the SNTP protocol as defined by RFC 5905, the NTPv4
IETF specification.
@@ -176,7 +176,7 @@ the usage text by passing it through a pager program.
used to select the program, defaulting to <span class="file">more</span>. Both will exit
with a status code of 0.
-<pre class="example">sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p5
+<pre class="example">sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p6
Usage: sntp [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... \
[ hostname-or-IP ...]
Flg Arg Option-Name Description
diff --git a/contrib/ntp/sntp/sntp.man.in b/contrib/ntp/sntp/sntp.man.in
index 1d5e571..c223eb5 100644
--- a/contrib/ntp/sntp/sntp.man.in
+++ b/contrib/ntp/sntp/sntp.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH sntp @SNTP_MS@ "07 Jan 2016" "4.2.8p5" "User Commands"
+.TH sntp @SNTP_MS@ "20 Jan 2016" "4.2.8p6" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-e.aO3S/ag-r.aG2S)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-vxaitn/ag-Ixaasn)
.\"
-.\" It has been AutoGen-ed January 7, 2016 at 11:23:20 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed January 20, 2016 at 04:06:38 AM by AutoGen 5.18.5
.\" From the definitions sntp-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
@@ -348,7 +348,7 @@ it to autogen-users@lists.sourceforge.net. Thank you.
.NOP "Dave Hart"
.br
.SH "COPYRIGHT"
-Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2016 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH "BUGS"
Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/sntp/sntp.mdoc.in b/contrib/ntp/sntp/sntp.mdoc.in
index 5168a99..2e15332 100644
--- a/contrib/ntp/sntp/sntp.mdoc.in
+++ b/contrib/ntp/sntp/sntp.mdoc.in
@@ -1,9 +1,9 @@
-.Dd January 7 2016
+.Dd January 20 2016
.Dt SNTP @SNTP_MS@ User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (sntp-opts.mdoc)
.\"
-.\" It has been AutoGen-ed January 7, 2016 at 11:23:27 PM by AutoGen 5.18.5
+.\" It has been AutoGen-ed January 20, 2016 at 04:06:45 AM by AutoGen 5.18.5
.\" From the definitions sntp-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@@ -303,7 +303,7 @@ it to autogen\-users@lists.sourceforge.net. Thank you.
.An "Harlan Stenn"
.An "Dave Hart"
.Sh "COPYRIGHT"
-Copyright (C) 1992\-2015 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2016 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh "BUGS"
Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/sntp/tests/crypto.c b/contrib/ntp/sntp/tests/crypto.c
index 82d2859..fb2dc62 100644
--- a/contrib/ntp/sntp/tests/crypto.c
+++ b/contrib/ntp/sntp/tests/crypto.c
@@ -18,8 +18,8 @@ void test_PacketSizeNotMultipleOfFourBytes(void);
void
-test_MakeMd5Mac(void) {
-
+test_MakeMd5Mac(void)
+{
const char* PKT_DATA = "abcdefgh0123";
const int PKT_LEN = strlen(PKT_DATA);
const char* EXPECTED_DIGEST =
@@ -34,15 +34,17 @@ test_MakeMd5Mac(void) {
memcpy(&md5.type, "MD5", 4);
TEST_ASSERT_EQUAL(MD5_LENGTH,
- make_mac((char*)PKT_DATA, PKT_LEN, MD5_LENGTH, &md5, actual));
+ make_mac(PKT_DATA, PKT_LEN, MD5_LENGTH, &md5, actual));
TEST_ASSERT_TRUE(memcmp(EXPECTED_DIGEST, actual, MD5_LENGTH) == 0);
}
void
-test_MakeSHA1Mac(void) {
+test_MakeSHA1Mac(void)
+{
#ifdef OPENSSL
+
const char* PKT_DATA = "abcdefgh0123";
const int PKT_LEN = strlen(PKT_DATA);
const char* EXPECTED_DIGEST =
@@ -58,22 +60,26 @@ test_MakeSHA1Mac(void) {
memcpy(&sha1.type, "SHA1", 5);
TEST_ASSERT_EQUAL(SHA1_LENGTH,
- make_mac((char*)PKT_DATA, PKT_LEN, SHA1_LENGTH, &sha1, actual));
+ make_mac(PKT_DATA, PKT_LEN, SHA1_LENGTH, &sha1, actual));
TEST_ASSERT_EQUAL_MEMORY(EXPECTED_DIGEST, actual, SHA1_LENGTH);
+
#else
+
TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
+
#endif /* OPENSSL */
}
void
-test_VerifyCorrectMD5(void) {
+test_VerifyCorrectMD5(void)
+{
const char* PKT_DATA =
- "sometestdata" // Data
- "\0\0\0\0" // Key-ID (unused)
- "\xc7\x58\x99\xdd\x99\x32\x0f\x71" // MAC
- "\x2b\x7b\xfe\x4f\xa2\x32\xcf\xac";
+ "sometestdata" /* Data */
+ "\0\0\0\0" /* Key-ID (unused) */
+ "\xc7\x58\x99\xdd\x99\x32\x0f\x71" /* MAC */
+ "\x2b\x7b\xfe\x4f\xa2\x32\xcf\xac";
const int PKT_LEN = 12;
struct key md5;
@@ -83,18 +89,20 @@ test_VerifyCorrectMD5(void) {
memcpy(&md5.key_seq, "md5key", md5.key_len);
memcpy(&md5.type, "MD5", 4);
- TEST_ASSERT_TRUE(auth_md5((char*)PKT_DATA, PKT_LEN, MD5_LENGTH, &md5));
+ TEST_ASSERT_TRUE(auth_md5(PKT_DATA, PKT_LEN, MD5_LENGTH, &md5));
}
void
-test_VerifySHA1(void) {
+test_VerifySHA1(void)
+{
#ifdef OPENSSL
+
const char* PKT_DATA =
- "sometestdata" // Data
- "\0\0\0\0" // Key-ID (unused)
- "\xad\x07\xde\x36\x39\xa6\x77\xfa\x5b\xce" // MAC
- "\x2d\x8a\x7d\x06\x96\xe6\x0c\xbc\xed\xe1";
+ "sometestdata" /* Data */
+ "\0\0\0\0" /* Key-ID (unused) */
+ "\xad\x07\xde\x36\x39\xa6\x77\xfa\x5b\xce" /* MAC */
+ "\x2d\x8a\x7d\x06\x96\xe6\x0c\xbc\xed\xe1";
const int PKT_LEN = 12;
struct key sha1;
@@ -104,21 +112,26 @@ test_VerifySHA1(void) {
memcpy(&sha1.key_seq, "sha1key", sha1.key_len);
memcpy(&sha1.type, "SHA1", 5);
- TEST_ASSERT_TRUE(auth_md5((char*)PKT_DATA, PKT_LEN, SHA1_LENGTH, &sha1));
+ TEST_ASSERT_TRUE(auth_md5(PKT_DATA, PKT_LEN, SHA1_LENGTH, &sha1));
+
#else
+
TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
+
#endif /* OPENSSL */
}
void
-test_VerifyFailure(void) {
- /* We use a copy of the MD5 verification code, but modify
- * the last bit to make sure verification fails. */
+test_VerifyFailure(void)
+{
+ /* We use a copy of the MD5 verification code, but modify the
+ * last bit to make sure verification fails.
+ */
const char* PKT_DATA =
- "sometestdata" // Data
- "\0\0\0\0" // Key-ID (unused)
- "\xc7\x58\x99\xdd\x99\x32\x0f\x71" // MAC
- "\x2b\x7b\xfe\x4f\xa2\x32\xcf\x00"; // Last byte is wrong!
+ "sometestdata" /* Data */
+ "\0\0\0\0" /* Key-ID (unused) */
+ "\xc7\x58\x99\xdd\x99\x32\x0f\x71" /* MAC */
+ "\x2b\x7b\xfe\x4f\xa2\x32\xcf\x00"; /* Last byte is wrong! */
const int PKT_LEN = 12;
struct key md5;
@@ -128,12 +141,13 @@ test_VerifyFailure(void) {
memcpy(&md5.key_seq, "md5key", md5.key_len);
memcpy(&md5.type, "MD5", 4);
- TEST_ASSERT_FALSE(auth_md5((char*)PKT_DATA, PKT_LEN, MD5_LENGTH, &md5));
+ TEST_ASSERT_FALSE(auth_md5(PKT_DATA, PKT_LEN, MD5_LENGTH, &md5));
}
void
-test_PacketSizeNotMultipleOfFourBytes(void) {
+test_PacketSizeNotMultipleOfFourBytes(void)
+{
const char* PKT_DATA = "123456";
const int PKT_LEN = 6;
char actual[MD5_LENGTH];
@@ -145,5 +159,5 @@ test_PacketSizeNotMultipleOfFourBytes(void) {
memcpy(&md5.key_seq, "md5seq", md5.key_len);
memcpy(&md5.type, "MD5", 4);
- TEST_ASSERT_EQUAL(0, make_mac((char*)PKT_DATA, PKT_LEN, MD5_LENGTH, &md5, actual));
+ TEST_ASSERT_EQUAL(0, make_mac(PKT_DATA, PKT_LEN, MD5_LENGTH, &md5, actual));
}
diff --git a/contrib/ntp/sntp/tests/fileHandlingTest.c b/contrib/ntp/sntp/tests/fileHandlingTest.c
index ce3f0de..8acad54 100644
--- a/contrib/ntp/sntp/tests/fileHandlingTest.c
+++ b/contrib/ntp/sntp/tests/fileHandlingTest.c
@@ -3,35 +3,52 @@
#include "stdlib.h"
#include "sntptest.h"
-#include "fileHandlingTest.h" //required because of the h.in thingy
+#include "fileHandlingTest.h" /* required because of the h.in thingy */
#include <string.h>
#include <unistd.h>
-/*
-enum DirectoryType {
- INPUT_DIR = 0,
- OUTPUT_DIR = 1
-};
-*/
-//extern const char srcdir[];
-
const char *
-CreatePath(const char* filename, enum DirectoryType argument) {
- const char srcdir[] = SRCDIR_DEF;//"@abs_srcdir@/data/";
- char * path = emalloc (sizeof (char) * (strlen(srcdir) + 256));
-
- //char cwd[1024];
+CreatePath(
+ const char * filename,
+ enum DirectoryType argument
+ )
+{
+ const char srcdir[] = SRCDIR_DEF;//"@abs_srcdir@/data/";
+ size_t plen = sizeof(srcdir) + strlen(filename) + 1;
+ char * path = emalloc(plen);
+ ssize_t retc;
+
+ UNUSED_ARG(argument);
+
+ retc = snprintf(path, plen, "%s%s", srcdir, filename);
+ if (retc <= 0 || (size_t)retc >= plen)
+ exit(1);
+ return path;
+}
- strcpy(path, srcdir);
- strcat(path, filename);
- return path;
+void
+DestroyPath(
+ const char * pathname
+ )
+{
+ /* use a union to get terminally rid of the 'const' attribute */
+ union {
+ const char *ccp;
+ void *vp;
+ } any;
+
+ any.ccp = pathname;
+ free(any.vp);
}
int
-GetFileSize(FILE *file) {
+GetFileSize(
+ FILE * file
+ )
+{
fseek(file, 0L, SEEK_END);
int length = ftell(file);
fseek(file, 0L, SEEK_SET);
@@ -41,7 +58,11 @@ GetFileSize(FILE *file) {
bool
-CompareFileContent(FILE* expected, FILE* actual) {
+CompareFileContent(
+ FILE * expected,
+ FILE * actual
+ )
+{
int currentLine = 1;
char actualLine[1024];
@@ -67,8 +88,10 @@ CompareFileContent(FILE* expected, FILE* actual) {
void
-ClearFile(const char * filename) {
+ClearFile(
+ const char * filename
+ )
+{
if (!truncate(filename, 0))
exit(1);
}
-
diff --git a/contrib/ntp/sntp/tests/fileHandlingTest.h.in b/contrib/ntp/sntp/tests/fileHandlingTest.h.in
index e7d99ee..b93ed9e 100644
--- a/contrib/ntp/sntp/tests/fileHandlingTest.h.in
+++ b/contrib/ntp/sntp/tests/fileHandlingTest.h.in
@@ -15,21 +15,12 @@ enum DirectoryType {
};
#define SRCDIR_DEF "@abs_srcdir@/data/";
-//const char srcdir[] = "@abs_srcdir@/data/";
-
-const char *
-CreatePath(const char* filename, enum DirectoryType argument);
-
-
-int
-GetFileSize(FILE *file);
-
-
-bool
-CompareFileContent(FILE* expected, FILE* actual);
-
-void
-ClearFile(const char * filename) ;
+extern const char * CreatePath(const char* filename,
+ enum DirectoryType argument);
+extern void DestroyPath(const char* pathname);
+extern int GetFileSize(FILE *file);
+extern bool CompareFileContent(FILE* expected, FILE* actual);
+extern void ClearFile(const char * filename) ;
#endif // FILE_HANDLING_TEST_H
diff --git a/contrib/ntp/sntp/tests/keyFile.c b/contrib/ntp/sntp/tests/keyFile.c
index 883658a..395ca0d 100644
--- a/contrib/ntp/sntp/tests/keyFile.c
+++ b/contrib/ntp/sntp/tests/keyFile.c
@@ -17,24 +17,28 @@ void test_ReadKeyFileWithInvalidHex(void);
bool
-CompareKeys(struct key expected, struct key actual) {
- if (expected.key_id != actual.key_id){
- printf("Expected key_id: %d", expected.key_id);
- printf(" but was: %d\n", actual.key_id);
+CompareKeys(
+ struct key expected,
+ struct key actual
+ )
+{
+ if (expected.key_id != actual.key_id) {
+ printf("Expected key_id: %d but was: %d\n",
+ expected.key_id, actual.key_id);
return FALSE;
}
- if (expected.key_len != actual.key_len){
- printf("Expected key_len: %d", expected.key_len);
- printf(" but was: %d\n", actual.key_len);
+ if (expected.key_len != actual.key_len) {
+ printf("Expected key_len: %d but was: %d\n",
+ expected.key_len, actual.key_len);
return FALSE;
}
- if (strcmp(expected.type, actual.type) != 0){
- printf("Expected key_type: %s", expected.type);
- printf(" but was: %s\n", actual.type);
+ if (strcmp(expected.type, actual.type) != 0) {
+ printf("Expected key_type: %s but was: %s\n",
+ expected.type, actual.type);
return FALSE;
}
- if (memcmp(expected.key_seq, actual.key_seq, expected.key_len) != 0){
+ if (memcmp(expected.key_seq, actual.key_seq, expected.key_len) != 0) {
printf("Key mismatch!\n");
return FALSE;
}
@@ -43,12 +47,15 @@ CompareKeys(struct key expected, struct key actual) {
bool
-CompareKeysAlternative(int key_id,
- int key_len,
- const char* type,
- const char* key_seq,
- struct key actual) {
- struct key temp;
+CompareKeysAlternative(
+ int key_id,
+ int key_len,
+ const char * type,
+ const char * key_seq,
+ struct key actual
+ )
+{
+ struct key temp;
temp.key_id = key_id;
temp.key_len = key_len;
@@ -60,30 +67,32 @@ CompareKeysAlternative(int key_id,
void
-test_ReadEmptyKeyFile(void) {
- struct key* keys = NULL;
- const char *path = CreatePath("key-test-empty", INPUT_DIR);
+test_ReadEmptyKeyFile(void)
+{
+ struct key * keys = NULL;
+ const char * path = CreatePath("key-test-empty", INPUT_DIR);
TEST_ASSERT_NOT_NULL(path);
TEST_ASSERT_EQUAL(0, auth_init(path, &keys));
TEST_ASSERT_NULL(keys);
- free((void *)path);
+ DestroyPath(path);
}
void
-test_ReadASCIIKeys(void) {
- struct key* keys = NULL;
- const char *path = CreatePath("key-test-ascii", INPUT_DIR);
+test_ReadASCIIKeys(void)
+{
+ struct key * keys = NULL;
+ struct key * result = NULL;
+ const char * path = CreatePath("key-test-ascii", INPUT_DIR);
TEST_ASSERT_NOT_NULL(path);
TEST_ASSERT_EQUAL(2, auth_init(path, &keys));
TEST_ASSERT_NOT_NULL(keys);
- free((void *)path);
+ DestroyPath(path);
- struct key* result = NULL;
get_key(40, &result);
TEST_ASSERT_NOT_NULL(result);
TEST_ASSERT_TRUE(CompareKeysAlternative(40, 11, "MD5", "asciikeyTwo", *result));
@@ -96,16 +105,19 @@ test_ReadASCIIKeys(void) {
void
-test_ReadHexKeys(void) {
- struct key* keys = NULL;
- const char *path = CreatePath("key-test-hex", INPUT_DIR);
+test_ReadHexKeys(void)
+{
+ struct key * keys = NULL;
+ struct key * result = NULL;
+ const char * path = CreatePath("key-test-hex", INPUT_DIR);
+ char data1[15];
+ char data2[13];
TEST_ASSERT_NOT_NULL(path);
TEST_ASSERT_EQUAL(3, auth_init(path, &keys));
TEST_ASSERT_NOT_NULL(keys);
- free((void *)path);
+ DestroyPath(path);
- struct key* result = NULL;
get_key(10, &result);
TEST_ASSERT_NOT_NULL(result);
TEST_ASSERT_TRUE(CompareKeysAlternative(10, 13, "MD5",
@@ -114,31 +126,36 @@ test_ReadHexKeys(void) {
result = NULL;
get_key(20, &result);
TEST_ASSERT_NOT_NULL(result);
- char data1[15]; memset(data1, 0x11, 15);
+
+ memset(data1, 0x11, 15);
TEST_ASSERT_TRUE(CompareKeysAlternative(20, 15, "MD5", data1, *result));
result = NULL;
get_key(30, &result);
TEST_ASSERT_NOT_NULL(result);
- char data2[13]; memset(data2, 0x01, 13);
+
+ memset(data2, 0x01, 13);
TEST_ASSERT_TRUE(CompareKeysAlternative(30, 13, "MD5", data2, *result));
}
void
-test_ReadKeyFileWithComments(void) {
- struct key* keys = NULL;
- const char *path = CreatePath("key-test-comments", INPUT_DIR);
+test_ReadKeyFileWithComments(void)
+{
+ struct key * keys = NULL;
+ struct key * result = NULL;
+ const char * path = CreatePath("key-test-comments", INPUT_DIR);
+ char data[15];
TEST_ASSERT_NOT_NULL(path);
TEST_ASSERT_EQUAL(2, auth_init(path, &keys));
TEST_ASSERT_NOT_NULL(keys);
- free((void *)path);
+ DestroyPath(path);
- struct key* result = NULL;
get_key(10, &result);
TEST_ASSERT_NOT_NULL(result);
- char data[15]; memset(data, 0x01, 15);
+
+ memset(data, 0x01, 15);
TEST_ASSERT_TRUE(CompareKeysAlternative(10, 15, "MD5", data, *result));
result = NULL;
@@ -149,22 +166,25 @@ test_ReadKeyFileWithComments(void) {
void
-test_ReadKeyFileWithInvalidHex(void) {
- struct key* keys = NULL;
- const char *path = CreatePath("key-test-invalid-hex", INPUT_DIR);
+test_ReadKeyFileWithInvalidHex(void)
+{
+ struct key * keys = NULL;
+ struct key * result = NULL;
+ const char * path = CreatePath("key-test-invalid-hex", INPUT_DIR);
+ char data[15];
TEST_ASSERT_NOT_NULL(path);
TEST_ASSERT_EQUAL(1, auth_init(path, &keys));
TEST_ASSERT_NOT_NULL(keys);
- free((void *)path);
+ DestroyPath(path);
- struct key* result = NULL;
get_key(10, &result);
TEST_ASSERT_NOT_NULL(result);
- char data[15]; memset(data, 0x01, 15);
+
+ memset(data, 0x01, 15);
TEST_ASSERT_TRUE(CompareKeysAlternative(10, 15, "MD5", data, *result));
result = NULL;
- get_key(30, &result); // Should not exist, and result should remain NULL.
+ get_key(30, &result); /* Should not exist, and result should remain NULL. */
TEST_ASSERT_NULL(result);
}
diff --git a/contrib/ntp/sntp/tests/packetHandling.c b/contrib/ntp/sntp/tests/packetHandling.c
index 1036fc3..595efa3 100644
--- a/contrib/ntp/sntp/tests/packetHandling.c
+++ b/contrib/ntp/sntp/tests/packetHandling.c
@@ -27,25 +27,29 @@ void test_HandleCorrectPacket(void);
void
-setUp(void) {
+setUp(void)
+{
init_lib();
}
int
-LfpEquality(const l_fp expected, const l_fp actual) {
- if (L_ISEQU(&expected, &actual))
- return TRUE;
- else
- return FALSE;
+LfpEquality(
+ const l_fp expected,
+ const l_fp actual
+ )
+{
+ return !!(L_ISEQU(&expected, &actual));
}
void
-test_GenerateUnauthenticatedPacket(void) {
- struct pkt testpkt;
+test_GenerateUnauthenticatedPacket(void)
+{
+ struct pkt testpkt;
+ struct timeval xmt;
+ l_fp expected_xmt, actual_xmt;
- struct timeval xmt;
GETTIMEOFDAY(&xmt, NULL);
xmt.tv_sec += JAN_1970;
@@ -59,7 +63,6 @@ test_GenerateUnauthenticatedPacket(void) {
TEST_ASSERT_EQUAL(STRATUM_UNSPEC, PKT_TO_STRATUM(testpkt.stratum));
TEST_ASSERT_EQUAL(8, testpkt.ppoll);
- l_fp expected_xmt, actual_xmt;
TVTOTS(&xmt, &expected_xmt);
NTOHL_FP(&testpkt.xmt, &actual_xmt);
TEST_ASSERT_TRUE(LfpEquality(expected_xmt, actual_xmt));
@@ -67,22 +70,25 @@ test_GenerateUnauthenticatedPacket(void) {
void
-test_GenerateAuthenticatedPacket(void) {
- struct key testkey;
+test_GenerateAuthenticatedPacket(void)
+{
+ static const int EXPECTED_PKTLEN = LEN_PKT_NOMAC + MAX_MD5_LEN;
+
+ struct key testkey;
+ struct pkt testpkt;
+ struct timeval xmt;
+ l_fp expected_xmt, actual_xmt;
+ char expected_mac[MAX_MD5_LEN];
+
testkey.next = NULL;
testkey.key_id = 30;
testkey.key_len = 9;
memcpy(testkey.key_seq, "123456789", testkey.key_len);
memcpy(testkey.type, "MD5", 3);
- struct pkt testpkt;
-
- struct timeval xmt;
GETTIMEOFDAY(&xmt, NULL);
xmt.tv_sec += JAN_1970;
- const int EXPECTED_PKTLEN = LEN_PKT_NOMAC + MAX_MD5_LEN;
-
TEST_ASSERT_EQUAL(EXPECTED_PKTLEN,
generate_pkt(&testpkt, &xmt, testkey.key_id, &testkey));
@@ -93,103 +99,102 @@ test_GenerateAuthenticatedPacket(void) {
TEST_ASSERT_EQUAL(STRATUM_UNSPEC, PKT_TO_STRATUM(testpkt.stratum));
TEST_ASSERT_EQUAL(8, testpkt.ppoll);
- l_fp expected_xmt, actual_xmt;
TVTOTS(&xmt, &expected_xmt);
NTOHL_FP(&testpkt.xmt, &actual_xmt);
TEST_ASSERT_TRUE(LfpEquality(expected_xmt, actual_xmt));
TEST_ASSERT_EQUAL(testkey.key_id, ntohl(testpkt.exten[0]));
- char expected_mac[MAX_MD5_LEN];
- TEST_ASSERT_EQUAL(MAX_MD5_LEN - 4, // Remove the key_id, only keep the mac.
- make_mac((char*)&testpkt, LEN_PKT_NOMAC, MAX_MD5_LEN, &testkey, expected_mac));
+ TEST_ASSERT_EQUAL(MAX_MD5_LEN - 4, /* Remove the key_id, only keep the mac. */
+ make_mac(&testpkt, LEN_PKT_NOMAC, MAX_MD5_LEN, &testkey, expected_mac));
TEST_ASSERT_EQUAL_MEMORY(expected_mac, (char*)&testpkt.exten[1], MAX_MD5_LEN -4);
}
void
-test_OffsetCalculationPositiveOffset(void) {
- struct pkt rpkt;
-
- rpkt.precision = -16; // 0,000015259
+test_OffsetCalculationPositiveOffset(void)
+{
+ struct pkt rpkt;
+ l_fp reftime, tmp;
+ struct timeval dst;
+ double offset, precision, synch_distance;
+
+ rpkt.precision = -16; /* 0,000015259 */
rpkt.rootdelay = HTONS_FP(DTOUFP(0.125));
rpkt.rootdisp = HTONS_FP(DTOUFP(0.25));
- // Synch Distance: (0.125+0.25)/2.0 == 0.1875
- l_fp reftime;
+
+ /* Synch Distance: (0.125+0.25)/2.0 == 0.1875 */
get_systime(&reftime);
HTONL_FP(&reftime, &rpkt.reftime);
- l_fp tmp;
-
- // T1 - Originate timestamp
+ /* T1 - Originate timestamp */
tmp.l_ui = 1000000000UL;
tmp.l_uf = 0UL;
HTONL_FP(&tmp, &rpkt.org);
- // T2 - Receive timestamp
+ /* T2 - Receive timestamp */
tmp.l_ui = 1000000001UL;
tmp.l_uf = 2147483648UL;
HTONL_FP(&tmp, &rpkt.rec);
- // T3 - Transmit timestamp
+ /* T3 - Transmit timestamp */
tmp.l_ui = 1000000002UL;
tmp.l_uf = 0UL;
HTONL_FP(&tmp, &rpkt.xmt);
- // T4 - Destination timestamp as standard timeval
+ /* T4 - Destination timestamp as standard timeval */
tmp.l_ui = 1000000001UL;
tmp.l_uf = 0UL;
- struct timeval dst;
TSTOTV(&tmp, &dst);
dst.tv_sec -= JAN_1970;
- double offset, precision, synch_distance;
offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &synch_distance);
TEST_ASSERT_EQUAL_DOUBLE(1.25, offset);
TEST_ASSERT_EQUAL_DOUBLE(1. / ULOGTOD(16), precision);
- // 1.1250150000000001 ?
+ /* 1.1250150000000001 ? */
TEST_ASSERT_EQUAL_DOUBLE(1.125015, synch_distance);
}
void
-test_OffsetCalculationNegativeOffset(void) {
- struct pkt rpkt;
+test_OffsetCalculationNegativeOffset(void)
+{
+ struct pkt rpkt;
+ l_fp reftime, tmp;
+ struct timeval dst;
+ double offset, precision, synch_distance;
rpkt.precision = -1;
rpkt.rootdelay = HTONS_FP(DTOUFP(0.5));
rpkt.rootdisp = HTONS_FP(DTOUFP(0.5));
- // Synch Distance is (0.5+0.5)/2.0, or 0.5
- l_fp reftime;
+
+ /* Synch Distance is (0.5+0.5)/2.0, or 0.5 */
get_systime(&reftime);
HTONL_FP(&reftime, &rpkt.reftime);
- l_fp tmp;
-
- // T1 - Originate timestamp
+ /* T1 - Originate timestamp */
tmp.l_ui = 1000000001UL;
tmp.l_uf = 0UL;
HTONL_FP(&tmp, &rpkt.org);
- // T2 - Receive timestamp
+ /* T2 - Receive timestamp */
tmp.l_ui = 1000000000UL;
tmp.l_uf = 2147483648UL;
HTONL_FP(&tmp, &rpkt.rec);
- // T3 - Transmit timestamp
+ /*/ T3 - Transmit timestamp */
tmp.l_ui = 1000000001UL;
tmp.l_uf = 2147483648UL;
HTONL_FP(&tmp, &rpkt.xmt);
- // T4 - Destination timestamp as standard timeval
+ /* T4 - Destination timestamp as standard timeval */
tmp.l_ui = 1000000003UL;
tmp.l_uf = 0UL;
- struct timeval dst;
+
TSTOTV(&tmp, &dst);
dst.tv_sec -= JAN_1970;
- double offset, precision, synch_distance;
offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &synch_distance);
TEST_ASSERT_EQUAL_DOUBLE(-1, offset);
@@ -199,8 +204,9 @@ test_OffsetCalculationNegativeOffset(void) {
void
-test_HandleUnusableServer(void) {
- struct pkt rpkt;
+test_HandleUnusableServer(void)
+{
+ struct pkt rpkt;
sockaddr_u host;
int rpktl;
@@ -212,8 +218,9 @@ test_HandleUnusableServer(void) {
void
-test_HandleUnusablePacket(void) {
- struct pkt rpkt;
+test_HandleUnusablePacket(void)
+{
+ struct pkt rpkt;
sockaddr_u host;
int rpktl;
@@ -225,8 +232,9 @@ test_HandleUnusablePacket(void) {
void
-test_HandleServerAuthenticationFailure(void) {
- struct pkt rpkt;
+test_HandleServerAuthenticationFailure(void)
+{
+ struct pkt rpkt;
sockaddr_u host;
int rpktl;
@@ -238,12 +246,13 @@ test_HandleServerAuthenticationFailure(void) {
void
-test_HandleKodDemobilize(void) {
- const char * HOSTNAME = "192.0.2.1";
- const char * REASON = "DENY";
+test_HandleKodDemobilize(void)
+{
+ static const char * HOSTNAME = "192.0.2.1";
+ static const char * REASON = "DENY";
struct pkt rpkt;
- sockaddr_u host;
- int rpktl;
+ sockaddr_u host;
+ int rpktl;
struct kod_entry * entry;
rpktl = KOD_DEMOBILIZE;
@@ -253,7 +262,7 @@ test_HandleKodDemobilize(void) {
host.sa4.sin_family = AF_INET;
host.sa4.sin_addr.s_addr = inet_addr(HOSTNAME);
- // Test that the KOD-entry is added to the database.
+ /* Test that the KOD-entry is added to the database. */
kod_init_kod_db("/dev/null", TRUE);
TEST_ASSERT_EQUAL(1, handle_pkt(rpktl, &rpkt, &host, HOSTNAME));
@@ -264,8 +273,9 @@ test_HandleKodDemobilize(void) {
void
-test_HandleKodRate(void) {
- struct pkt rpkt;
+test_HandleKodRate(void)
+{
+ struct pkt rpkt;
sockaddr_u host;
int rpktl;
@@ -277,13 +287,14 @@ test_HandleKodRate(void) {
void
-test_HandleCorrectPacket(void) {
- struct pkt rpkt;
+test_HandleCorrectPacket(void)
+{
+ struct pkt rpkt;
sockaddr_u host;
int rpktl;
l_fp now;
- // We don't want our testing code to actually change the system clock.
+ /* We don't want our testing code to actually change the system clock. */
TEST_ASSERT_FALSE(ENABLED_OPT(STEP));
TEST_ASSERT_FALSE(ENABLED_OPT(SLEW));
diff --git a/contrib/ntp/sntp/tests/packetProcessing.c b/contrib/ntp/sntp/tests/packetProcessing.c
index 1fd649e..88e61cc 100644
--- a/contrib/ntp/sntp/tests/packetProcessing.c
+++ b/contrib/ntp/sntp/tests/packetProcessing.c
@@ -1,4 +1,10 @@
#include "config.h"
+
+/* need autokey for some of the tests, or the will create buffer overruns. */
+#ifndef AUTOKEY
+# define AUTOKEY 1
+#endif
+
#include "sntptest.h"
#include "networking.h"
#include "ntp_stdlib.h"
@@ -43,10 +49,13 @@ bool restoreKeyDb;
void
-PrepareAuthenticationTest(int key_id,
- int key_len,
- const char* type,
- const void* key_seq) {
+PrepareAuthenticationTest(
+ int key_id,
+ int key_len,
+ const char * type,
+ const void * key_seq
+ )
+{
char str[25];
snprintf(str, 25, "%d", key_id);
ActivateOption("-a", str);
@@ -66,28 +75,34 @@ PrepareAuthenticationTest(int key_id,
void
-PrepareAuthenticationTestMD5(int key_id,
- int key_len,
- const void* key_seq) {
+PrepareAuthenticationTestMD5(
+ int key_id,
+ int key_len,
+ const void * key_seq
+ )
+{
PrepareAuthenticationTest(key_id, key_len, "MD5", key_seq);
}
void
-setUp(void) {
+setUp(void)
+{
sntptest();
restoreKeyDb = false;
/* Initialize the test packet and socket,
- * so they contain at least some valid data. */
+ * so they contain at least some valid data.
+ */
testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING, NTP_VERSION,
MODE_SERVER);
testpkt.stratum = STRATUM_REFCLOCK;
memcpy(&testpkt.refid, "GPS\0", 4);
/* Set the origin timestamp of the received packet to the
- * same value as the transmit timestamp of the sent packet. */
+ * same value as the transmit timestamp of the sent packet.
+ */
l_fp tmp;
tmp.l_ui = 1000UL;
tmp.l_uf = 0UL;
@@ -98,189 +113,202 @@ setUp(void) {
void
-tearDown(void) {
-
+tearDown(void)
+{
if (restoreKeyDb) {
key_cnt = 0;
free(key_ptr);
key_ptr = NULL;
}
- sntptest_destroy(); //only on the final test!! if counter == 0 etc...
+ sntptest_destroy(); /* only on the final test!! if counter == 0 etc... */
}
-
void
-test_TooShortLength(void) {
+test_TooShortLength(void)
+{
TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC - 1,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC - 1,
- MODE_BROADCAST, &testspkt, "UnitTest"));
+ MODE_BROADCAST, &testspkt, "UnitTest"));
}
void
-test_LengthNotMultipleOfFour(void) {
+test_LengthNotMultipleOfFour(void)
+{
TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC + 6,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC + 3,
- MODE_BROADCAST, &testspkt, "UnitTest"));
+ MODE_BROADCAST, &testspkt, "UnitTest"));
}
void
-test_TooShortExtensionFieldLength(void) {
+test_TooShortExtensionFieldLength(void)
+{
/* The lower 16-bits are the length of the extension field.
* This lengths must be multiples of 4 bytes, which gives
- * a minimum of 4 byte extension field length. */
- testpkt.exten[7] = htonl(3); // 3 bytes is too short.
+ * a minimum of 4 byte extension field length.
+ */
+ testpkt.exten[7] = htonl(3); /* 3 bytes is too short. */
/* We send in a pkt_len of header size + 4 byte extension
* header + 24 byte MAC, this prevents the length error to
- * be caught at an earlier stage */
+ * be caught at an earlier stage
+ */
int pkt_len = LEN_PKT_NOMAC + 4 + 24;
TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
process_pkt(&testpkt, &testsock, pkt_len,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_UnauthenticatedPacketReject(void) {
- //sntptest();
- // Activate authentication option
+test_UnauthenticatedPacketReject(void)
+{
+ /* Activate authentication option */
ActivateOption("-a", "123");
TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
int pkt_len = LEN_PKT_NOMAC;
- // We demand authentication, but no MAC header is present.
+ /* We demand authentication, but no MAC header is present. */
TEST_ASSERT_EQUAL(SERVER_AUTH_FAIL,
process_pkt(&testpkt, &testsock, pkt_len,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_CryptoNAKPacketReject(void) {
- // Activate authentication option
+test_CryptoNAKPacketReject(void)
+{
+ /* Activate authentication option */
ActivateOption("-a", "123");
TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
- int pkt_len = LEN_PKT_NOMAC + 4; // + 4 byte MAC = Crypto-NAK
+ int pkt_len = LEN_PKT_NOMAC + 4; /* + 4 byte MAC = Crypto-NAK */
TEST_ASSERT_EQUAL(SERVER_AUTH_FAIL,
process_pkt(&testpkt, &testsock, pkt_len,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_AuthenticatedPacketInvalid(void) {
- // Activate authentication option
+test_AuthenticatedPacketInvalid(void)
+{
+ /* Activate authentication option */
PrepareAuthenticationTestMD5(50, 9, "123456789");
TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
- // Prepare the packet.
+ /* Prepare the packet. */
int pkt_len = LEN_PKT_NOMAC;
testpkt.exten[0] = htonl(50);
- int mac_len = make_mac((char*)&testpkt, pkt_len,
- MAX_MD5_LEN, key_ptr,
- (char*)&testpkt.exten[1]);
+ int mac_len = make_mac(&testpkt, pkt_len,
+ MAX_MD5_LEN, key_ptr,
+ &testpkt.exten[1]);
pkt_len += 4 + mac_len;
- // Now, alter the MAC so it becomes invalid.
+ /* Now, alter the MAC so it becomes invalid. */
testpkt.exten[1] += 1;
TEST_ASSERT_EQUAL(SERVER_AUTH_FAIL,
process_pkt(&testpkt, &testsock, pkt_len,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_AuthenticatedPacketUnknownKey(void) {
- // Activate authentication option
+test_AuthenticatedPacketUnknownKey(void)
+{
+ /* Activate authentication option */
PrepareAuthenticationTestMD5(30, 9, "123456789");
TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
- // Prepare the packet. Observe that the Key-ID expected is 30,
- // but the packet has a key id of 50.
+ /* Prepare the packet. Note that the Key-ID expected is 30, but
+ * the packet has a key id of 50.
+ */
int pkt_len = LEN_PKT_NOMAC;
testpkt.exten[0] = htonl(50);
- int mac_len = make_mac((char*)&testpkt, pkt_len,
- MAX_MD5_LEN, key_ptr,
- (char*)&testpkt.exten[1]);
+ int mac_len = make_mac(&testpkt, pkt_len,
+ MAX_MD5_LEN, key_ptr,
+ &testpkt.exten[1]);
pkt_len += 4 + mac_len;
TEST_ASSERT_EQUAL(SERVER_AUTH_FAIL,
process_pkt(&testpkt, &testsock, pkt_len,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_ServerVersionTooOld(void) {
+test_ServerVersionTooOld(void)
+{
TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
- NTP_OLDVERSION - 1,
- MODE_CLIENT);
+ NTP_OLDVERSION - 1,
+ MODE_CLIENT);
TEST_ASSERT_TRUE(PKT_VERSION(testpkt.li_vn_mode) < NTP_OLDVERSION);
int pkt_len = LEN_PKT_NOMAC;
TEST_ASSERT_EQUAL(SERVER_UNUSEABLE,
process_pkt(&testpkt, &testsock, pkt_len,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_ServerVersionTooNew(void) {
+test_ServerVersionTooNew(void)
+{
TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
- NTP_VERSION + 1,
- MODE_CLIENT);
+ NTP_VERSION + 1,
+ MODE_CLIENT);
TEST_ASSERT_TRUE(PKT_VERSION(testpkt.li_vn_mode) > NTP_VERSION);
int pkt_len = LEN_PKT_NOMAC;
TEST_ASSERT_EQUAL(SERVER_UNUSEABLE,
process_pkt(&testpkt, &testsock, pkt_len,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_NonWantedMode(void) {
+test_NonWantedMode(void)
+{
TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
- NTP_VERSION,
- MODE_CLIENT);
-
- // The packet has a mode of MODE_CLIENT, but process_pkt expects MODE_SERVER
+ NTP_VERSION,
+ MODE_CLIENT);
+ /* The packet has a mode of MODE_CLIENT, but process_pkt expects
+ * MODE_SERVER
+ */
TEST_ASSERT_EQUAL(SERVER_UNUSEABLE,
process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
/* Tests bug 1597 */
void
-test_KoDRate(void) {
+test_KoDRate(void)
+{
TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
testpkt.stratum = STRATUM_PKT_UNSPEC;
@@ -288,12 +316,13 @@ test_KoDRate(void) {
TEST_ASSERT_EQUAL(KOD_RATE,
process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_KoDDeny(void) {
+test_KoDDeny(void)
+{
TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
testpkt.stratum = STRATUM_PKT_UNSPEC;
@@ -301,26 +330,28 @@ test_KoDDeny(void) {
TEST_ASSERT_EQUAL(KOD_DEMOBILIZE,
process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_RejectUnsyncedServer(void) {
+test_RejectUnsyncedServer(void)
+{
TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOTINSYNC,
- NTP_VERSION,
- MODE_SERVER);
+ NTP_VERSION,
+ MODE_SERVER);
TEST_ASSERT_EQUAL(SERVER_UNUSEABLE,
process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_RejectWrongResponseServerMode(void) {
+test_RejectWrongResponseServerMode(void)
+{
TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
l_fp tmp;
@@ -334,12 +365,13 @@ test_RejectWrongResponseServerMode(void) {
TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_AcceptNoSentPacketBroadcastMode(void) {
+test_AcceptNoSentPacketBroadcastMode(void)
+{
TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
@@ -353,53 +385,55 @@ test_AcceptNoSentPacketBroadcastMode(void) {
void
-test_CorrectUnauthenticatedPacket(void) {
+test_CorrectUnauthenticatedPacket(void)
+{
TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
TEST_ASSERT_EQUAL(LEN_PKT_NOMAC,
process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_CorrectAuthenticatedPacketMD5(void) {
+test_CorrectAuthenticatedPacketMD5(void)
+{
PrepareAuthenticationTestMD5(10, 15, "123456789abcdef");
TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
int pkt_len = LEN_PKT_NOMAC;
- // Prepare the packet.
+ /* Prepare the packet. */
testpkt.exten[0] = htonl(10);
- int mac_len = make_mac((char*)&testpkt, pkt_len,
- MAX_MD5_LEN, key_ptr,
- (char*)&testpkt.exten[1]);
+ int mac_len = make_mac(&testpkt, pkt_len,
+ MAX_MD5_LEN, key_ptr,
+ &testpkt.exten[1]);
pkt_len += 4 + mac_len;
TEST_ASSERT_EQUAL(pkt_len,
process_pkt(&testpkt, &testsock, pkt_len,
- MODE_SERVER, &testspkt, "UnitTest"));
-
+ MODE_SERVER, &testspkt, "UnitTest"));
}
void
-test_CorrectAuthenticatedPacketSHA1(void) {
+test_CorrectAuthenticatedPacketSHA1(void)
+{
PrepareAuthenticationTest(20, 15, "SHA1", "abcdefghijklmno");
TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
int pkt_len = LEN_PKT_NOMAC;
- // Prepare the packet.
+ /* Prepare the packet. */
testpkt.exten[0] = htonl(20);
- int mac_len = make_mac((char*)&testpkt, pkt_len,
- MAX_MAC_LEN, key_ptr,
- (char*)&testpkt.exten[1]);
+ int mac_len = make_mac(&testpkt, pkt_len,
+ MAX_MAC_LEN, key_ptr,
+ &testpkt.exten[1]);
pkt_len += 4 + mac_len;
TEST_ASSERT_EQUAL(pkt_len,
process_pkt(&testpkt, &testsock, pkt_len,
- MODE_SERVER, &testspkt, "UnitTest"));
+ MODE_SERVER, &testspkt, "UnitTest"));
}
diff --git a/contrib/ntp/sntp/tests/run-packetProcessing.c b/contrib/ntp/sntp/tests/run-packetProcessing.c
index bf3a63e..ad02b7a 100644
--- a/contrib/ntp/sntp/tests/run-packetProcessing.c
+++ b/contrib/ntp/sntp/tests/run-packetProcessing.c
@@ -66,24 +66,24 @@ int main(int argc, char *argv[])
{
progname = argv[0];
UnityBegin("packetProcessing.c");
- RUN_TEST(test_TooShortLength, 19);
- RUN_TEST(test_LengthNotMultipleOfFour, 20);
- RUN_TEST(test_TooShortExtensionFieldLength, 21);
- RUN_TEST(test_UnauthenticatedPacketReject, 22);
- RUN_TEST(test_CryptoNAKPacketReject, 23);
- RUN_TEST(test_AuthenticatedPacketInvalid, 24);
- RUN_TEST(test_AuthenticatedPacketUnknownKey, 25);
- RUN_TEST(test_ServerVersionTooOld, 26);
- RUN_TEST(test_ServerVersionTooNew, 27);
- RUN_TEST(test_NonWantedMode, 28);
- RUN_TEST(test_KoDRate, 29);
- RUN_TEST(test_KoDDeny, 30);
- RUN_TEST(test_RejectUnsyncedServer, 31);
- RUN_TEST(test_RejectWrongResponseServerMode, 32);
- RUN_TEST(test_AcceptNoSentPacketBroadcastMode, 33);
- RUN_TEST(test_CorrectUnauthenticatedPacket, 34);
- RUN_TEST(test_CorrectAuthenticatedPacketMD5, 35);
- RUN_TEST(test_CorrectAuthenticatedPacketSHA1, 36);
+ RUN_TEST(test_TooShortLength, 25);
+ RUN_TEST(test_LengthNotMultipleOfFour, 26);
+ RUN_TEST(test_TooShortExtensionFieldLength, 27);
+ RUN_TEST(test_UnauthenticatedPacketReject, 28);
+ RUN_TEST(test_CryptoNAKPacketReject, 29);
+ RUN_TEST(test_AuthenticatedPacketInvalid, 30);
+ RUN_TEST(test_AuthenticatedPacketUnknownKey, 31);
+ RUN_TEST(test_ServerVersionTooOld, 32);
+ RUN_TEST(test_ServerVersionTooNew, 33);
+ RUN_TEST(test_NonWantedMode, 34);
+ RUN_TEST(test_KoDRate, 35);
+ RUN_TEST(test_KoDDeny, 36);
+ RUN_TEST(test_RejectUnsyncedServer, 37);
+ RUN_TEST(test_RejectWrongResponseServerMode, 38);
+ RUN_TEST(test_AcceptNoSentPacketBroadcastMode, 39);
+ RUN_TEST(test_CorrectUnauthenticatedPacket, 40);
+ RUN_TEST(test_CorrectAuthenticatedPacketMD5, 41);
+ RUN_TEST(test_CorrectAuthenticatedPacketSHA1, 42);
return (UnityEnd());
}
diff --git a/contrib/ntp/sntp/unity/unity_internals.h b/contrib/ntp/sntp/unity/unity_internals.h
index bf1bf3d..f1cc400 100644
--- a/contrib/ntp/sntp/unity/unity_internals.h
+++ b/contrib/ntp/sntp/unity/unity_internals.h
@@ -614,7 +614,7 @@ extern const char UnityStrErr64[];
#define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UP)(expected), (_U_SINT)(_UP)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_POINTER)
#define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)line)
-#define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((UNITY_PTR_ATTRIBUTE void*)(expected), (UNITY_PTR_ATTRIBUTE void*)(actual), (_UU32)(len), 1, (message), (UNITY_LINE_TYPE)line)
+#define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(len), 1, (message), (UNITY_LINE_TYPE)line)
#define UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
#define UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT8)
diff --git a/contrib/ntp/sntp/version.c b/contrib/ntp/sntp/version.c
index eb0e92b..762eeb7 100644
--- a/contrib/ntp/sntp/version.c
+++ b/contrib/ntp/sntp/version.c
@@ -2,4 +2,4 @@
* version file for sntp
*/
#include <config.h>
-const char * Version = "sntp 4.2.8p4@1.3265-o Thu Jan 7 23:23:18 UTC 2016 (26)";
+const char * Version = "sntp 4.2.8p5@1.3265-o Wed Jan 20 09:06:36 UTC 2016 (27)";
OpenPOWER on IntegriCloud