]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
unit1302: slightly extended
authorDaniel Stenberg <daniel@haxx.se>
Mon, 5 Dec 2022 09:08:53 +0000 (10:08 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 6 Dec 2022 07:57:04 +0000 (08:57 +0100)
To test more base64 decoding

tests/unit/unit1302.c

index afc5716626307570d6bebf28a7cc65aae4e76e47..a9f37b53f8fdd4e145cab8fc4571be158afb4a8e 100644 (file)
@@ -169,6 +169,15 @@ fail_unless(rc == CURLE_BAD_CONTENT_ENCODING,
 fail_unless(size == 0, "size should be 0");
 fail_if(decoded, "returned pointer should be NULL");
 
+/* This is also illegal input as it contains a padding character mid input */
+size = 1; /* not zero */
+decoded = &anychar; /* not NULL */
+rc = Curl_base64_decode("aWlpa=Q=", &decoded, &size);
+fail_unless(rc == CURLE_BAD_CONTENT_ENCODING,
+            "return code should be CURLE_BAD_CONTENT_ENCODING");
+fail_unless(size == 0, "size should be 0");
+fail_if(decoded, "returned pointer should be NULL");
+
 /* This is garbage input as it contains an illegal base64 character */
 size = 1; /* not zero */
 decoded = &anychar; /* not NULL */
@@ -178,4 +187,5 @@ fail_unless(rc == CURLE_BAD_CONTENT_ENCODING,
 fail_unless(size == 0, "size should be 0");
 fail_if(decoded, "returned pointer should be NULL");
 
+
 UNITTEST_STOP