diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-08-21 14:20:38 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-08-21 14:20:38 -0400 |
commit | 6f3208670a11cc7f0c5917852d28890b07ab87d2 (patch) | |
tree | a972baf5ac34881fe8cdf9b72ed6f4ecd3ea5a39 /src/test/test_hs_descriptor.c | |
parent | 257f50b22fbaf9c9cb5859e257437b24af46c7ab (diff) | |
parent | 6be0e28670517048ce3ab017911cd41238543a13 (diff) | |
download | tor-6f3208670a11cc7f0c5917852d28890b07ab87d2.tar.gz tor-6f3208670a11cc7f0c5917852d28890b07ab87d2.zip |
Merge branch 'maint-0.3.1'
Diffstat (limited to 'src/test/test_hs_descriptor.c')
-rw-r--r-- | src/test/test_hs_descriptor.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/test_hs_descriptor.c b/src/test/test_hs_descriptor.c index 77bdd4be5e..ab6a43ec70 100644 --- a/src/test/test_hs_descriptor.c +++ b/src/test/test_hs_descriptor.c @@ -19,6 +19,14 @@ #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) @@ -554,6 +562,27 @@ test_decode_invalid_intro_point(void *arg) hs_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); + + setup_full_capture_of_logs(LOG_WARN); + ret = hs_desc_decode_plaintext(HS_DESC_BAD_SIG, &desc_plaintext); + tt_int_op(ret, OP_EQ, -1); + expect_log_msg_containing("Malformed signature line. Rejecting."); + teardown_capture_of_logs(); + + done: ; +} + static void test_decode_plaintext(void *arg) { @@ -844,6 +873,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, |