diff options
author | Alexander Færøy <ahf@torproject.org> | 2020-06-30 13:48:49 +0000 |
---|---|---|
committer | Alexander Færøy <ahf@torproject.org> | 2020-06-30 13:48:49 +0000 |
commit | 483082b57bfb2535477530fe84d8c92c70be2fa1 (patch) | |
tree | 445b76b652d86a3cde5fe738930b4d7faae9f4a1 /src/test/test_pem.c | |
parent | b0bfee8c783b495ece772189d478dad2628bc159 (diff) | |
parent | c3ad2a1d2367d6c0ba5c1c81491770056e881a77 (diff) | |
download | tor-483082b57bfb2535477530fe84d8c92c70be2fa1.tar.gz tor-483082b57bfb2535477530fe84d8c92c70be2fa1.zip |
Merge branch 'maint-0.3.5' into maint-0.4.2
Diffstat (limited to 'src/test/test_pem.c')
-rw-r--r-- | src/test/test_pem.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/test_pem.c b/src/test/test_pem.c index 865688b1a7..9eb99181e2 100644 --- a/src/test/test_pem.c +++ b/src/test/test_pem.c @@ -115,8 +115,38 @@ test_crypto_pem_decode(void *arg) ; } +static void +test_crypto_pem_decode_crlf(void *arg) +{ + (void)arg; + char crlf_version[4096]; + uint8_t buf[4096]; + + /* Convert 'expected' to a version with CRLF instead of LF. */ + const char *inp = expected; + char *outp = crlf_version; + while (*inp) { + if (*inp == '\n') { + *outp++ = '\r'; + } + *outp++ = *inp++; + } + *outp = 0; + + /* Decoding should succeed (or else we have bug 33032 again) */ + int n = pem_decode(buf, sizeof(buf), + crlf_version, strlen(crlf_version), + "WOMBAT QUOTE"); + tt_int_op(n, OP_EQ, strlen(example_pre)); + tt_mem_op(buf, OP_EQ, example_pre, n); + + done: + ; +} + struct testcase_t pem_tests[] = { { "encode", test_crypto_pem_encode, 0, NULL, NULL }, { "decode", test_crypto_pem_decode, 0, NULL, NULL }, + { "decode_crlf", test_crypto_pem_decode_crlf, 0, NULL, NULL }, END_OF_TESTCASES }; |