Sanity check input length in OPENSSL_uni2asc().
authorDr. Stephen Henson <steve@openssl.org>
Fri, 5 Aug 2016 16:59:32 +0000 (17:59 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 5 Aug 2016 18:00:34 +0000 (19:00 +0100)
Thanks to Hanno Böck for reporting this bug.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 39a43280316f1b9c45be5ac5b04f4f5c3f923686)

Conflicts:
crypto/pkcs12/p12_utl.c

crypto/pkcs12/p12_utl.c

index a0b992eab66cc0fe7c9a06c5fec134334d209050..e466f762ffda2eff91e7bc30f765de048799f270 100644 (file)
@@ -91,6 +91,10 @@ char *OPENSSL_uni2asc(unsigned char *uni, int unilen)
 {
     int asclen, i;
     char *asctmp;
+
+    /* string must contain an even number of bytes */
+    if (unilen & 1)
+        return NULL;
     asclen = unilen / 2;
     /* If no terminating zero allow for one */
     if (!unilen || uni[unilen - 1])