diff options
author | George Kadianakis <desnacked@riseup.net> | 2017-08-17 23:12:59 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2017-08-21 19:16:30 +0300 |
commit | 45732a1a13cb05107f5822afed0c01388096be27 (patch) | |
tree | 0a3192305a89d88aa92f6aa31aed30fb8a4af13c /src/test/test_hs_descriptor.c | |
parent | 72832086e2144158308b30133aa15b39f0d2eb5d (diff) | |
download | tor-45732a1a13cb05107f5822afed0c01388096be27.tar.gz tor-45732a1a13cb05107f5822afed0c01388096be27.zip |
Add unittest for #23233.
This will fail currently since the bug is not fixed yet.
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, |