]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
unit: add IncorrectBase64Encoding test
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 13 Jan 2011 18:34:35 +0000 (10:34 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 13 Jan 2011 18:34:35 +0000 (10:34 -0800)
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/test/base64.cc

index 0612bfa207f1d5d220b526c8d540d0dbaf890054..2cf6d71fed8d30f42dc97ce227811445056939fb 100644 (file)
@@ -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);
+}