diff options
author | Xin LI <delphij@FreeBSD.org> | 2016-04-27 07:46:38 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2016-04-27 07:46:38 +0000 |
commit | 4990d495fcc77c51b3f46c91ba3a064b565afae0 (patch) | |
tree | 89c803d8ff6ef95cafc2a4cb08de66848195099a /contrib/ntp/tests | |
parent | 0fbe6eaef6fbb001b91bd8a57a9b3817c1b07b24 (diff) | |
parent | c1950318d1af96666bb3a80bf73cb4790f6dbcea (diff) |
MFV r298691:
ntp 4.2.8p7.
Security: CVE-2016-1547, CVE-2016-1548, CVE-2016-1549, CVE-2016-1550
Security: CVE-2016-1551, CVE-2016-2516, CVE-2016-2517, CVE-2016-2518
Security: CVE-2016-2519
Security: FreeBSD-SA-16:16.ntp
With hat: so
Notes
Notes:
svn path=/head/; revision=298695
Diffstat (limited to 'contrib/ntp/tests')
-rw-r--r-- | contrib/ntp/tests/libntp/Makefile.am | 12 | ||||
-rw-r--r-- | contrib/ntp/tests/libntp/Makefile.in | 61 | ||||
-rw-r--r-- | contrib/ntp/tests/libntp/lfpfunc.c | 3 | ||||
-rw-r--r-- | contrib/ntp/tests/libntp/run-lfpfunc.c | 18 | ||||
-rw-r--r-- | contrib/ntp/tests/libntp/run-timevalops.c | 56 | ||||
-rw-r--r-- | contrib/ntp/tests/libntp/run-tsafememcmp.c | 64 | ||||
-rw-r--r-- | contrib/ntp/tests/libntp/ssl_init.c | 4 | ||||
-rw-r--r-- | contrib/ntp/tests/libntp/timespecops.c | 2 | ||||
-rw-r--r-- | contrib/ntp/tests/libntp/timevalops.c | 2 | ||||
-rw-r--r-- | contrib/ntp/tests/libntp/tsafememcmp.c | 85 | ||||
-rw-r--r-- | contrib/ntp/tests/ntpq/Makefile.am | 1 | ||||
-rw-r--r-- | contrib/ntp/tests/ntpq/Makefile.in | 3 |
12 files changed, 251 insertions, 60 deletions
diff --git a/contrib/ntp/tests/libntp/Makefile.am b/contrib/ntp/tests/libntp/Makefile.am index 7bfe9eea8859..f8360a9e27e4 100644 --- a/contrib/ntp/tests/libntp/Makefile.am +++ b/contrib/ntp/tests/libntp/Makefile.am @@ -42,6 +42,7 @@ check_PROGRAMS = \ test-strtolfp \ test-timespecops \ test-timevalops \ + test-tsafememcmp \ test-tstotv \ test-tvtots \ test-uglydate \ @@ -102,6 +103,7 @@ BUILT_SOURCES += \ $(srcdir)/run-strtolfp.c \ $(srcdir)/run-timevalops.c \ $(srcdir)/run-timespecops.c \ + $(srcdir)/run-tsafememcmp.c \ $(srcdir)/run-tstotv.c \ $(srcdir)/run-tvtots.c \ $(srcdir)/run-uglydate.c \ @@ -477,6 +479,16 @@ $(srcdir)/run-timevalops.c: $(srcdir)/timevalops.c $(std_unity_list) ### +test_tsafememcmp_SOURCES = \ + tsafememcmp.c \ + run-tsafememcmp.c \ + $(NULL) + +$(srcdir)/run-tsafememcmp.c: $(srcdir)/tsafememcmp.c $(std_unity_list) + $(run_unity) tsafememcmp.c run-tsafememcmp.c + +### + test_tstotv_SOURCES = \ tstotv.c \ run-tstotv.c \ diff --git a/contrib/ntp/tests/libntp/Makefile.in b/contrib/ntp/tests/libntp/Makefile.in index 32e884bda194..87dd3192ee9f 100644 --- a/contrib/ntp/tests/libntp/Makefile.in +++ b/contrib/ntp/tests/libntp/Makefile.in @@ -104,9 +104,10 @@ check_PROGRAMS = test-a_md5encrypt$(EXEEXT) test-atoint$(EXEEXT) \ test-sfptostr$(EXEEXT) test-socktoa$(EXEEXT) \ test-ssl_init$(EXEEXT) test-statestr$(EXEEXT) \ test-strtolfp$(EXEEXT) test-timespecops$(EXEEXT) \ - test-timevalops$(EXEEXT) test-tstotv$(EXEEXT) \ - test-tvtots$(EXEEXT) test-uglydate$(EXEEXT) \ - test-vi64ops$(EXEEXT) test-ymd2yd$(EXEEXT) $(am__EXEEXT_1) + test-timevalops$(EXEEXT) test-tsafememcmp$(EXEEXT) \ + test-tstotv$(EXEEXT) test-tvtots$(EXEEXT) \ + test-uglydate$(EXEEXT) test-vi64ops$(EXEEXT) \ + test-ymd2yd$(EXEEXT) $(am__EXEEXT_1) @NTP_CROSSCOMPILE_FALSE@am__append_1 = $(check_PROGRAMS) subdir = tests/libntp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -446,6 +447,14 @@ test_timevalops_DEPENDENCIES = $(top_builddir)/libntp/libntp.a \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(top_builddir)/sntp/unity/libunity.a $(am__DEPENDENCIES_1) +am_test_tsafememcmp_OBJECTS = tsafememcmp.$(OBJEXT) \ + run-tsafememcmp.$(OBJEXT) $(am__objects_1) +test_tsafememcmp_OBJECTS = $(am_test_tsafememcmp_OBJECTS) +test_tsafememcmp_LDADD = $(LDADD) +test_tsafememcmp_DEPENDENCIES = $(top_builddir)/libntp/libntp.a \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/sntp/unity/libunity.a $(am__DEPENDENCIES_1) am_test_tstotv_OBJECTS = tstotv.$(OBJEXT) run-tstotv.$(OBJEXT) \ $(am__objects_1) test_tstotv_OBJECTS = $(am_test_tstotv_OBJECTS) @@ -536,9 +545,10 @@ SOURCES = $(test_a_md5encrypt_SOURCES) $(test_atoint_SOURCES) \ $(test_sfptostr_SOURCES) $(test_socktoa_SOURCES) \ $(test_ssl_init_SOURCES) $(test_statestr_SOURCES) \ $(test_strtolfp_SOURCES) $(test_timespecops_SOURCES) \ - $(test_timevalops_SOURCES) $(test_tstotv_SOURCES) \ - $(test_tvtots_SOURCES) $(test_uglydate_SOURCES) \ - $(test_vi64ops_SOURCES) $(test_ymd2yd_SOURCES) + $(test_timevalops_SOURCES) $(test_tsafememcmp_SOURCES) \ + $(test_tstotv_SOURCES) $(test_tvtots_SOURCES) \ + $(test_uglydate_SOURCES) $(test_vi64ops_SOURCES) \ + $(test_ymd2yd_SOURCES) DIST_SOURCES = $(test_a_md5encrypt_SOURCES) $(test_atoint_SOURCES) \ $(test_atouint_SOURCES) $(test_authkeys_SOURCES) \ $(test_buftvtots_SOURCES) $(test_calendar_SOURCES) \ @@ -555,9 +565,10 @@ DIST_SOURCES = $(test_a_md5encrypt_SOURCES) $(test_atoint_SOURCES) \ $(test_sfptostr_SOURCES) $(test_socktoa_SOURCES) \ $(test_ssl_init_SOURCES) $(test_statestr_SOURCES) \ $(test_strtolfp_SOURCES) $(test_timespecops_SOURCES) \ - $(test_timevalops_SOURCES) $(test_tstotv_SOURCES) \ - $(test_tvtots_SOURCES) $(test_uglydate_SOURCES) \ - $(test_vi64ops_SOURCES) $(test_ymd2yd_SOURCES) + $(test_timevalops_SOURCES) $(test_tsafememcmp_SOURCES) \ + $(test_tstotv_SOURCES) $(test_tvtots_SOURCES) \ + $(test_uglydate_SOURCES) $(test_vi64ops_SOURCES) \ + $(test_ymd2yd_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -1077,10 +1088,11 @@ BUILT_SOURCES = $(srcdir)/run-a_md5encrypt.c $(srcdir)/run-atoint.c \ $(srcdir)/run-sfptostr.c $(srcdir)/run-socktoa.c \ $(srcdir)/run-ssl_init.c $(srcdir)/run-statestr.c \ $(srcdir)/run-strtolfp.c $(srcdir)/run-timevalops.c \ - $(srcdir)/run-timespecops.c $(srcdir)/run-tstotv.c \ - $(srcdir)/run-tvtots.c $(srcdir)/run-uglydate.c \ - $(srcdir)/run-vi64ops.c $(srcdir)/run-ymd2yd.c $(NULL) \ - check-libntp check-libunity .deps-ver + $(srcdir)/run-timespecops.c $(srcdir)/run-tsafememcmp.c \ + $(srcdir)/run-tstotv.c $(srcdir)/run-tvtots.c \ + $(srcdir)/run-uglydate.c $(srcdir)/run-vi64ops.c \ + $(srcdir)/run-ymd2yd.c $(NULL) check-libntp check-libunity \ + .deps-ver CLEANFILES = check-libntp check-libunity .deps-ver std_unity_list = \ $(top_srcdir)/sntp/unity/auto/generate_test_runner.rb \ @@ -1369,6 +1381,13 @@ test_timevalops_SOURCES = \ ### +test_tsafememcmp_SOURCES = \ + tsafememcmp.c \ + run-tsafememcmp.c \ + $(NULL) + + +### test_tstotv_SOURCES = \ tstotv.c \ run-tstotv.c \ @@ -1586,6 +1605,10 @@ test-timevalops$(EXEEXT): $(test_timevalops_OBJECTS) $(test_timevalops_DEPENDENC @rm -f test-timevalops$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_timevalops_OBJECTS) $(test_timevalops_LDADD) $(LIBS) +test-tsafememcmp$(EXEEXT): $(test_tsafememcmp_OBJECTS) $(test_tsafememcmp_DEPENDENCIES) $(EXTRA_test_tsafememcmp_DEPENDENCIES) + @rm -f test-tsafememcmp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_tsafememcmp_OBJECTS) $(test_tsafememcmp_LDADD) $(LIBS) + test-tstotv$(EXEEXT): $(test_tstotv_OBJECTS) $(test_tstotv_DEPENDENCIES) $(EXTRA_test_tstotv_DEPENDENCIES) @rm -f test-tstotv$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_tstotv_OBJECTS) $(test_tstotv_LDADD) $(LIBS) @@ -1665,6 +1688,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run-statestr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run-timespecops.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run-timevalops.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run-tsafememcmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run-tstotv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run-tvtots.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run-uglydate.Po@am__quote@ @@ -1689,6 +1713,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_strtolfp-strtolfp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timespecops.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timevalops.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsafememcmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tstotv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tvtots.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uglydate.Po@am__quote@ @@ -2300,6 +2325,13 @@ test-timevalops.log: test-timevalops$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +test-tsafememcmp.log: test-tsafememcmp$(EXEEXT) + @p='test-tsafememcmp$(EXEEXT)'; \ + b='test-tsafememcmp'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) test-tstotv.log: test-tstotv$(EXEEXT) @p='test-tstotv$(EXEEXT)'; \ b='test-tstotv'; \ @@ -2612,6 +2644,9 @@ $(srcdir)/run-timespecops.c: $(srcdir)/timespecops.c $(std_unity_list) $(srcdir)/run-timevalops.c: $(srcdir)/timevalops.c $(std_unity_list) $(run_unity) timevalops.c run-timevalops.c +$(srcdir)/run-tsafememcmp.c: $(srcdir)/tsafememcmp.c $(std_unity_list) + $(run_unity) tsafememcmp.c run-tsafememcmp.c + $(srcdir)/run-tstotv.c: $(srcdir)/tstotv.c $(std_unity_list) $(run_unity) tstotv.c run-tstotv.c diff --git a/contrib/ntp/tests/libntp/lfpfunc.c b/contrib/ntp/tests/libntp/lfpfunc.c index cedbb6082a4d..859bb744034a 100644 --- a/contrib/ntp/tests/libntp/lfpfunc.c +++ b/contrib/ntp/tests/libntp/lfpfunc.c @@ -21,9 +21,6 @@ } -typedef int bool; // typedef enum { FALSE, TRUE } boolean; -> can't use this because TRUE and FALSE are already defined - - typedef struct { uint32_t h, l; } lfp_hl; diff --git a/contrib/ntp/tests/libntp/run-lfpfunc.c b/contrib/ntp/tests/libntp/run-lfpfunc.c index 83f966815a47..5c7f658fa93b 100644 --- a/contrib/ntp/tests/libntp/run-lfpfunc.c +++ b/contrib/ntp/tests/libntp/run-lfpfunc.c @@ -58,15 +58,15 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("lfpfunc.c"); - RUN_TEST(test_AdditionLR, 51); - RUN_TEST(test_AdditionRL, 52); - RUN_TEST(test_SubtractionLR, 53); - RUN_TEST(test_SubtractionRL, 54); - RUN_TEST(test_Negation, 55); - RUN_TEST(test_Absolute, 56); - RUN_TEST(test_FDF_RoundTrip, 57); - RUN_TEST(test_SignedRelOps, 58); - RUN_TEST(test_UnsignedRelOps, 59); + RUN_TEST(test_AdditionLR, 48); + RUN_TEST(test_AdditionRL, 49); + RUN_TEST(test_SubtractionLR, 50); + RUN_TEST(test_SubtractionRL, 51); + RUN_TEST(test_Negation, 52); + RUN_TEST(test_Absolute, 53); + RUN_TEST(test_FDF_RoundTrip, 54); + RUN_TEST(test_SignedRelOps, 55); + RUN_TEST(test_UnsignedRelOps, 56); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-timevalops.c b/contrib/ntp/tests/libntp/run-timevalops.c index df39ab9c389a..69fead53cb52 100644 --- a/contrib/ntp/tests/libntp/run-timevalops.c +++ b/contrib/ntp/tests/libntp/run-timevalops.c @@ -77,34 +77,34 @@ int main(int argc, char *argv[]) { progname = argv[0]; UnityBegin("timevalops.c"); - RUN_TEST(test_Helpers1, 39); - RUN_TEST(test_Normalise, 40); - RUN_TEST(test_SignNoFrac, 41); - RUN_TEST(test_SignWithFrac, 42); - RUN_TEST(test_CmpFracEQ, 43); - RUN_TEST(test_CmpFracGT, 44); - RUN_TEST(test_CmpFracLT, 45); - RUN_TEST(test_AddFullNorm, 46); - RUN_TEST(test_AddFullOflow1, 47); - RUN_TEST(test_AddUsecNorm, 48); - RUN_TEST(test_AddUsecOflow1, 49); - RUN_TEST(test_SubFullNorm, 50); - RUN_TEST(test_SubFullOflow, 51); - RUN_TEST(test_SubUsecNorm, 52); - RUN_TEST(test_SubUsecOflow, 53); - RUN_TEST(test_Neg, 54); - RUN_TEST(test_AbsNoFrac, 55); - RUN_TEST(test_AbsWithFrac, 56); - RUN_TEST(test_Helpers2, 57); - RUN_TEST(test_ToLFPbittest, 58); - RUN_TEST(test_ToLFPrelPos, 59); - RUN_TEST(test_ToLFPrelNeg, 60); - RUN_TEST(test_ToLFPabs, 61); - RUN_TEST(test_FromLFPbittest, 62); - RUN_TEST(test_FromLFPrelPos, 63); - RUN_TEST(test_FromLFPrelNeg, 64); - RUN_TEST(test_LFProundtrip, 65); - RUN_TEST(test_ToString, 66); + RUN_TEST(test_Helpers1, 37); + RUN_TEST(test_Normalise, 38); + RUN_TEST(test_SignNoFrac, 39); + RUN_TEST(test_SignWithFrac, 40); + RUN_TEST(test_CmpFracEQ, 41); + RUN_TEST(test_CmpFracGT, 42); + RUN_TEST(test_CmpFracLT, 43); + RUN_TEST(test_AddFullNorm, 44); + RUN_TEST(test_AddFullOflow1, 45); + RUN_TEST(test_AddUsecNorm, 46); + RUN_TEST(test_AddUsecOflow1, 47); + RUN_TEST(test_SubFullNorm, 48); + RUN_TEST(test_SubFullOflow, 49); + RUN_TEST(test_SubUsecNorm, 50); + RUN_TEST(test_SubUsecOflow, 51); + RUN_TEST(test_Neg, 52); + RUN_TEST(test_AbsNoFrac, 53); + RUN_TEST(test_AbsWithFrac, 54); + RUN_TEST(test_Helpers2, 55); + RUN_TEST(test_ToLFPbittest, 56); + RUN_TEST(test_ToLFPrelPos, 57); + RUN_TEST(test_ToLFPrelNeg, 58); + RUN_TEST(test_ToLFPabs, 59); + RUN_TEST(test_FromLFPbittest, 60); + RUN_TEST(test_FromLFPrelPos, 61); + RUN_TEST(test_FromLFPrelNeg, 62); + RUN_TEST(test_LFProundtrip, 63); + RUN_TEST(test_ToString, 64); return (UnityEnd()); } diff --git a/contrib/ntp/tests/libntp/run-tsafememcmp.c b/contrib/ntp/tests/libntp/run-tsafememcmp.c new file mode 100644 index 000000000000..1bcfc9cda364 --- /dev/null +++ b/contrib/ntp/tests/libntp/run-tsafememcmp.c @@ -0,0 +1,64 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include <setjmp.h> +#include <stdio.h> +#include "config.h" +#include "ntp_stdlib.h" +#include "isc/string.h" + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_Empty(void); +extern void test_Equal(void); +extern void test_FirstByte(void); +extern void test_LastByte(void); +extern void test_MiddleByte(void); +extern void test_MiddleByteUpLo(void); + + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + +char const *progname; + + +//=======MAIN===== +int main(int argc, char *argv[]) +{ + progname = argv[0]; + UnityBegin("tsafememcmp.c"); + RUN_TEST(test_Empty, 10); + RUN_TEST(test_Equal, 11); + RUN_TEST(test_FirstByte, 12); + RUN_TEST(test_LastByte, 13); + RUN_TEST(test_MiddleByte, 14); + RUN_TEST(test_MiddleByteUpLo, 15); + + return (UnityEnd()); +} diff --git a/contrib/ntp/tests/libntp/ssl_init.c b/contrib/ntp/tests/libntp/ssl_init.c index 42fe920b6d26..435e5c912fd6 100644 --- a/contrib/ntp/tests/libntp/ssl_init.c +++ b/contrib/ntp/tests/libntp/ssl_init.c @@ -43,7 +43,7 @@ test_SHA1KeyTypeWithDigestLength(void) { size_t digestLength; size_t expected = TEST_SHA1_DIGEST_LENGTH; - TEST_ASSERT_EQUAL(NID_sha, keytype_from_text("SHA", &digestLength)); + TEST_ASSERT_EQUAL(NID_sha1, keytype_from_text("SHA1", &digestLength)); TEST_ASSERT_EQUAL(expected, digestLength); /* OPENSSL */ #else @@ -62,7 +62,7 @@ test_MD5KeyName(void) { void test_SHA1KeyName(void) { #ifdef OPENSSL - TEST_ASSERT_EQUAL_STRING("SHA", keytype_name(NID_sha)); + TEST_ASSERT_EQUAL_STRING("SHA1", keytype_name(NID_sha1)); #else TEST_IGNORE_MESSAGE("Skipping because OPENSSL isn't defined"); #endif /* OPENSSL */ diff --git a/contrib/ntp/tests/libntp/timespecops.c b/contrib/ntp/tests/libntp/timespecops.c index 68a472ab5f35..741b1adfe782 100644 --- a/contrib/ntp/tests/libntp/timespecops.c +++ b/contrib/ntp/tests/libntp/timespecops.c @@ -63,8 +63,6 @@ void test_FromLFPrelNeg(void); void test_LFProundtrip(void); void test_ToString(void); -typedef int bool; - const bool timespec_isValid(struct timespec V); struct timespec timespec_init(time_t hi, long lo); l_fp l_fp_init(int32 i, u_int32 f); diff --git a/contrib/ntp/tests/libntp/timevalops.c b/contrib/ntp/tests/libntp/timevalops.c index 99a48eb9a75b..20d589299228 100644 --- a/contrib/ntp/tests/libntp/timevalops.c +++ b/contrib/ntp/tests/libntp/timevalops.c @@ -27,8 +27,6 @@ typedef struct { u_int32 frac; } lfpfracdata ; -typedef int bool; - struct timeval timeval_init( time_t hi, long lo); const bool timeval_isValid(struct timeval V); l_fp l_fp_init(int32 i, u_int32 f); diff --git a/contrib/ntp/tests/libntp/tsafememcmp.c b/contrib/ntp/tests/libntp/tsafememcmp.c new file mode 100644 index 000000000000..7bd91584e464 --- /dev/null +++ b/contrib/ntp/tests/libntp/tsafememcmp.c @@ -0,0 +1,85 @@ +#include "config.h" + +#include "ntp_stdlib.h" +#include "isc/string.h" + +#include "unity.h" + +/* Basisc test for timingsafe_memcmp() */ + +void test_Empty(void); +void test_Equal(void); +void test_FirstByte(void); +void test_LastByte(void); +void test_MiddleByte(void); +void test_MiddleByteUpLo(void); + +void test_Empty(void) +{ + static const char dummy[1]; + TEST_ASSERT_EQUAL_INT(0, isc_tsmemcmp(NULL , NULL , 0)); + TEST_ASSERT_EQUAL_INT(0, isc_tsmemcmp(dummy, dummy, 0)); +} + +void test_Equal(void) +{ + static const char dummy[2][4] = { + "blob", "blob" + }; + TEST_ASSERT_EQUAL_INT(0, isc_tsmemcmp(dummy[0], + dummy[1], + sizeof(dummy[0]))); +} + +void test_FirstByte(void) +{ + static const char dummy[2][4] = { + "Blob", "Clob" + }; + TEST_ASSERT_EQUAL_INT(-1, isc_tsmemcmp(dummy[0], + dummy[1], + sizeof(dummy[0]))); + TEST_ASSERT_EQUAL_INT( 1, isc_tsmemcmp(dummy[1], + dummy[0], + sizeof(dummy[0]))); +} + +void test_LastByte(void) +{ + static const char dummy[2][4] = { + "Blob", "Bloc" + }; + TEST_ASSERT_EQUAL_INT(-1, isc_tsmemcmp(dummy[0], + dummy[1], + sizeof(dummy[0]))); + TEST_ASSERT_EQUAL_INT( 1, isc_tsmemcmp(dummy[1], + dummy[0], + sizeof(dummy[0]))); +} + +void test_MiddleByte(void) +{ + static const char dummy[2][4] = { + "Blob", "Blpb" + }; + TEST_ASSERT_EQUAL_INT(-1, isc_tsmemcmp(dummy[0], + dummy[1], + sizeof(dummy[0]))); + TEST_ASSERT_EQUAL_INT( 1, isc_tsmemcmp(dummy[1], + dummy[0], + sizeof(dummy[0]))); +} + +void test_MiddleByteUpLo(void) +{ + static const char dummy[2][4] = { + "Blob", "Blpa" + }; + TEST_ASSERT_EQUAL_INT(-1, isc_tsmemcmp(dummy[0], + dummy[1], + sizeof(dummy[0]))); + TEST_ASSERT_EQUAL_INT( 1, isc_tsmemcmp(dummy[1], + dummy[0], + sizeof(dummy[0]))); +} + diff --git a/contrib/ntp/tests/ntpq/Makefile.am b/contrib/ntp/tests/ntpq/Makefile.am index a45a9aec05dd..136b8f348f0a 100644 --- a/contrib/ntp/tests/ntpq/Makefile.am +++ b/contrib/ntp/tests/ntpq/Makefile.am @@ -34,6 +34,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/ntpq AM_CPPFLAGS += $(CPPFLAGS_NTP) AM_CPPFLAGS += -DUNITY_INCLUDE_CONFIG_H AM_CPPFLAGS += -I$(top_srcdir)/sntp/unity +AM_CPPFLAGS += $(LIBOPTS_CFLAGS) AM_LDFLAGS = $(LDFLAGS_NTP) diff --git a/contrib/ntp/tests/ntpq/Makefile.in b/contrib/ntp/tests/ntpq/Makefile.in index f31c0bcaf2ad..47e15d68812b 100644 --- a/contrib/ntp/tests/ntpq/Makefile.in +++ b/contrib/ntp/tests/ntpq/Makefile.in @@ -720,7 +720,8 @@ unity_tests_LDADD = \ AM_CFLAGS = $(CFLAGS_NTP) AM_CPPFLAGS = $(NTP_INCS) -I$(top_srcdir)/ntpq $(CPPFLAGS_NTP) \ - -DUNITY_INCLUDE_CONFIG_H -I$(top_srcdir)/sntp/unity + -DUNITY_INCLUDE_CONFIG_H -I$(top_srcdir)/sntp/unity \ + $(LIBOPTS_CFLAGS) AM_LDFLAGS = $(LDFLAGS_NTP) noinst_HEADERS = \ $(NULL) |