diff options
Diffstat (limited to 'src/test/test_hs_descriptor.c')
-rw-r--r-- | src/test/test_hs_descriptor.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/test_hs_descriptor.c b/src/test/test_hs_descriptor.c index b1abe381d4..5be0747085 100644 --- a/src/test/test_hs_descriptor.c +++ b/src/test/test_hs_descriptor.c @@ -19,6 +19,15 @@ #include "test_helpers.h" #include "log_test_helpers.h" + +#ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS +DISABLE_GCC_WARNING(overlength-strings) +/* We allow huge string constants in the unit tests, but not in the code + * at large. */ +#endif +#include "test_hs_descriptor.inc" +ENABLE_GCC_WARNING(overlength-strings) + /* Test certificate encoding put in a descriptor. */ static void test_cert_encoding(void *arg) @@ -548,6 +557,24 @@ test_decode_invalid_intro_point(void *arg) desc_intro_point_free(ip); } +/** Make sure we fail gracefully when decoding the bad desc from #23233. */ +static void +test_decode_bad_signature(void *arg) +{ + hs_desc_plaintext_data_t desc_plaintext; + int ret; + + (void) arg; + + /* Update approx time to dodge cert expiration */ + update_approx_time(1502661599); + + ret = hs_desc_decode_plaintext(HS_DESC_BAD_SIG, &desc_plaintext); + tt_int_op(ret, OP_EQ, -1); + + done: ; +} + static void test_decode_plaintext(void *arg) { @@ -838,6 +865,8 @@ struct testcase_t hs_descriptor[] = { NULL, NULL }, { "decode_plaintext", test_decode_plaintext, TT_FORK, NULL, NULL }, + { "decode_bad_signature", test_decode_bad_signature, TT_FORK, + NULL, NULL }, /* Misc. */ { "version", test_supported_version, TT_FORK, |