Fix a crash in the asn1parse command
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Sat, 31 Mar 2018 19:09:32 +0000 (21:09 +0200)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Tue, 3 Apr 2018 14:05:19 +0000 (16:05 +0200)
Thanks to Sem Voigtländer for reporting this issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5826)

(cherry picked from commit 752837e0664e990b5edf6f0b69e1b4612efadce0)

apps/asn1pars.c

index 1ac261c7629ecbb14b051d40e80e87343dc35ab3..39b9f8b0c89093a97030a37f2ed6aaa3aacf4efa 100644 (file)
@@ -212,7 +212,7 @@ int asn1parse_main(int argc, char **argv)
             ASN1_TYPE *atmp;
             int typ;
             j = atoi(sk_OPENSSL_STRING_value(osk, i));
-            if (j == 0) {
+            if (j <= 0 || j >= tmplen) {
                 BIO_printf(bio_err, "'%s' is an invalid number\n",
                            sk_OPENSSL_STRING_value(osk, i));
                 continue;