base64: fix possible null pointer dereference
[project/libubox.git] / tests / cram / test_base64.t
1 set test bin path:
2
3 $ [ -n "$TEST_BIN_DIR" ] && export PATH="$TEST_BIN_DIR:$PATH"
4
5 check that base64 is producing expected results:
6
7 $ valgrind --quiet --leak-check=full test-b64
8 0
9 4 Zg==
10 4 Zm8=
11 4 Zm9v
12 8 Zm9vYg==
13 8 Zm9vYmE=
14 8 Zm9vYmFy
15 0
16 1 f
17 2 fo
18 3 foo
19 4 foob
20 5 fooba
21 6 foobar
22
23 check that b64_encode and b64_decode assert invalid input
24
25 $ alias check="egrep '(dumped|Assertion)' | sed 's;.*\(b64_.*code\).*\(Assertion.*$\);\1: \2;' | LC_ALL=C sort"
26
27 $ test-b64_decode 2>&1 | check
28 Aborted (core dumped)
29 b64_decode: Assertion `dest && targsize > 0' failed.
30
31 $ test-b64_encode 2>&1 | check
32 Aborted (core dumped)
33 b64_encode: Assertion `dest && targsize > 0' failed.