Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/84088?usp=email )
Change subject: b64_decode-test: Properly terminate strings before comparison ......................................................................
b64_decode-test: Properly terminate strings before comparison
Undefined behavior in unit-tests is no fun. assert_string_equal() expects properly zero-terminated strings. None of the encoded test strings contain a termination, hence add it manually.
Change-Id: Id1bd2c3ff06bc1d4e5aa21ddd0f1d5802540999d Signed-off-by: Nico Huber nico.h@gmx.de --- M tests/lib/b64_decode-test.c 1 file changed, 3 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/88/84088/1
diff --git a/tests/lib/b64_decode-test.c b/tests/lib/b64_decode-test.c index 189ce96..8560eb2 100644 --- a/tests/lib/b64_decode-test.c +++ b/tests/lib/b64_decode-test.c @@ -35,6 +35,9 @@ res = b64_decode((uint8_t *)messages[i].enc, strlen(messages[i].enc), decoded);
assert_int_equal(res, (strlen(messages[i].dec))); + + decoded[res] = 0x00; + assert_string_equal((const char *)decoded, messages[i].dec);
free(decoded);