]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
asn.1: fix Coverity 1487104 Logically dead code
authorPauli <pauli@openssl.org>
Sun, 11 Jul 2021 10:53:43 +0000 (20:53 +1000)
committerPauli <pauli@openssl.org>
Mon, 12 Jul 2021 23:24:04 +0000 (09:24 +1000)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/16042)

crypto/asn1/tasn_enc.c

index 06473d3411a85ac89858ad92f368150deca0d4dd..3ea18b0280ddc5b692f1b807dc61f1b3d1eab4e9 100644 (file)
@@ -348,11 +348,12 @@ static int asn1_template_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
         /* EXPLICIT tagging */
         /* Find length of tagged item */
         i = ASN1_item_ex_i2d(pval, NULL, ASN1_ITEM_ptr(tt->item), -1, iclass);
-        if (!i)
+        if (i == 0) {
+            if ((tt->flags & ASN1_TFLG_OPTIONAL) == 0) {
+                ERR_raise(ERR_LIB_ASN1, ASN1_R_ILLEGAL_ZERO_CONTENT);
+                return -1;
+            }
             return 0;
-        if (i == 0 && (tt->flags & ASN1_TFLG_OPTIONAL) == 0) {
-            ERR_raise(ERR_LIB_ASN1, ASN1_R_ILLEGAL_ZERO_CONTENT);
-            return -1;
         }
         /* Find length of EXPLICIT tag */
         ret = ASN1_object_size(ndef, i, ttag);