From 4b2ffba95a0d64114409d4c929854bdcf697ed90 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Thu, 13 Jan 2011 10:34:35 -0800 Subject: [PATCH] unit: add IncorrectBase64Encoding test Signed-off-by: Colin McCabe --- src/test/base64.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/base64.cc b/src/test/base64.cc index 0612bfa207f1d..2cf6d71fed8d3 100644 --- a/src/test/base64.cc +++ b/src/test/base64.cc @@ -33,3 +33,12 @@ TEST(CorrectBase64Encoding, StringSimple) { ceph_unarmor(out2, out2 + OUT_LEN, out, out + alen); ASSERT_STREQ(original, out2); } + +TEST(IncorrectBase64Encoding, StringSimple) { + static const int OUT_LEN = 4096; + const char * const bad_encoded = "FAKEBASE64 foo"; + char out[OUT_LEN]; + memset(out, 0, sizeof(out)); + int alen = ceph_unarmor(out, out + OUT_LEN, bad_encoded, bad_encoded + strlen(bad_encoded)); + ASSERT_LT(alen, 0); +} -- 2.39.5