Subtract padding from outlen in ct_base64_decode
authorRob Percival <robpercival@google.com>
Wed, 19 Oct 2016 14:11:04 +0000 (15:11 +0100)
committerRich Salz <rsalz@openssl.org>
Wed, 16 Nov 2016 21:27:23 +0000 (16:27 -0500)
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1548)
(cherry picked from commit 70a06fc1a8b098e9934f837896159bfc6caf0228)

crypto/ct/ct_b64.c

index d13d8f2af2e99849ea6568af2d77e699ba049ff0..636ac4f5d24ddff30e5b589008668d7554f02ad4 100644 (file)
@@ -45,6 +45,11 @@ static int ct_base64_decode(const char *in, unsigned char **out)
         goto err;
     }
 
+    /* Subtract padding bytes from |outlen| */
+    while (in[--inlen] == '=') {
+        --outlen;
+    }
+
     *out = outbuf;
     return outlen;
 err: