diff options
author | Yann Ylavic <ylavic@apache.org> | 2020-11-27 17:04:06 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2020-11-27 17:04:06 +0000 |
commit | e70d77ecc4aa9e0dccac6e7e5ba74639f71f50cf (patch) | |
tree | 981901714607910bcc6c1f4e8f09bdada313cde2 /test/testencode.c | |
parent | 2b0eb50e43667ce8cebf0bb745a0eb7d493385c2 (diff) | |
download | apr-e70d77ecc4aa9e0dccac6e7e5ba74639f71f50cf.tar.gz |
apr_decode_base{64,32,16}: stop reading before (not including) NUL byte.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1883870 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testencode.c')
-rw-r--r-- | test/testencode.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/test/testencode.c b/test/testencode.c index 3680fa380..ba23aaf28 100644 --- a/test/testencode.c +++ b/test/testencode.c @@ -134,37 +134,42 @@ static void test_decode_base64(abts_case * tc, void *data) src = ""; target = ""; dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len); - ABTS_STR_EQUAL(tc, dest, target); + ABTS_STR_EQUAL(tc, target, dest); src = "Zg=="; target = "f"; dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len); - ABTS_STR_EQUAL(tc, dest, target); + ABTS_STR_EQUAL(tc, target, dest); + + src = "Zg="; + target = "f"; + dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len); + ABTS_STR_EQUAL(tc, target, dest); src = "Zg"; target = "f"; dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len); - ABTS_STR_EQUAL(tc, dest, target); + ABTS_STR_EQUAL(tc, target, dest); src = "Zm8="; target = "fo"; dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len); - ABTS_STR_EQUAL(tc, dest, target); + ABTS_STR_EQUAL(tc, target, dest); src = "Zm8"; target = "fo"; dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len); - ABTS_STR_EQUAL(tc, dest, target); + ABTS_STR_EQUAL(tc, target, dest); src = "Zm9v"; target = "foo"; dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len); - ABTS_STR_EQUAL(tc, dest, target); + ABTS_STR_EQUAL(tc, target, dest); src = "Zm9v"; target = "foo"; dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len); - ABTS_STR_EQUAL(tc, dest, target); + ABTS_STR_EQUAL(tc, target, dest); apr_pool_destroy(pool); } @@ -191,6 +196,11 @@ static void test_decode_base64_binary(abts_case * tc, void *data) ABTS_ASSERT(tc, "apr_pdecode_base64_binary target!=dest", memcmp(ufoobar, udest, 1) == 0); ABTS_INT_EQUAL(tc, len, 1); + src = "Zg="; + udest = apr_pdecode_base64_binary(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len); + ABTS_ASSERT(tc, "apr_pdecode_base64_binary target!=dest", memcmp(ufoobar, udest, 1) == 0); + ABTS_INT_EQUAL(tc, len, 1); + src = "Zg"; udest = apr_pdecode_base64_binary(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len); ABTS_ASSERT(tc, "apr_pdecode_base64_binary target!=dest", memcmp(ufoobar, udest, 1) == 0); |