Avoid special handling of definite length before calling asn1_find_end().
authorjsing <jsing@openbsd.org>
Wed, 4 May 2022 10:53:26 +0000 (10:53 +0000)
committerjsing <jsing@openbsd.org>
Wed, 4 May 2022 10:53:26 +0000 (10:53 +0000)
The asn1_find_end() function handles definite length ASN.1, which means
that there is no point in the only caller having code to explicitly handle
definite length - it can just call the function.

ok tb@

lib/libcrypto/asn1/tasn_dec.c

index a6614f1..7e41671 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: tasn_dec.c,v 1.55 2022/05/04 10:47:36 jsing Exp $ */
+/* $OpenBSD: tasn_dec.c,v 1.56 2022/05/04 10:53:26 jsing Exp $ */
 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project 2000.
  */
@@ -716,15 +716,9 @@ asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen,
                }
 
                content = *in;
-               /* If indefinite length constructed find the real end */
-               if (inf) {
-                       if (!asn1_find_end(&p, plen, inf))
-                               goto err;
-                       len = p - content;
-               } else {
-                       len = p - content + plen;
-                       p += plen;
-               }
+               if (!asn1_find_end(&p, plen, inf))
+                       goto err;
+               len = p - content;
        } else if (cst) {
                /*
                 * Should really check the internal tags are correct but