diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-12-14 13:07:55 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-12-14 13:51:51 -0500 |
commit | 3c35c0d441cc25f750524056113970a376d8432c (patch) | |
tree | e05e798bfd09e022db4908f0070026ec75d317ac /src/test | |
parent | cf7342ab6f653c2dc49134024d668b06bac2c96c (diff) | |
download | tor-3c35c0d441cc25f750524056113970a376d8432c.tar.gz tor-3c35c0d441cc25f750524056113970a376d8432c.zip |
Add a function to provide an upper bound on base64 decoded length
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_util_format.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/test/test_util_format.c b/src/test/test_util_format.c index 85d8a8e62e..fd57125b86 100644 --- a/src/test/test_util_format.c +++ b/src/test/test_util_format.c @@ -392,10 +392,13 @@ test_util_format_encoded_size(void *arg) base64_encode(outbuf, sizeof(outbuf), (char *)inbuf, i, 0); tt_int_op(strlen(outbuf), OP_EQ, base64_encode_size(i, 0)); + tt_int_op(i, OP_LE, base64_decode_maxsize(strlen(outbuf))); + base64_encode(outbuf, sizeof(outbuf), (char *)inbuf, i, BASE64_ENCODE_MULTILINE); tt_int_op(strlen(outbuf), OP_EQ, base64_encode_size(i, BASE64_ENCODE_MULTILINE)); + tt_int_op(i, OP_LE, base64_decode_maxsize(strlen(outbuf))); } done: @@ -417,4 +420,3 @@ struct testcase_t util_format_tests[] = { { "encoded_size", test_util_format_encoded_size, 0, NULL, NULL }, END_OF_TESTCASES }; - |