]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - fuzz/asn1.c
Copyright year updates
[thirdparty/openssl.git] / fuzz / asn1.c
index 1db219c3585deea12a2dff054e981d83980557b9..f7a019774b9ddd7881a32c574f761b07f8b7497c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -312,13 +312,20 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
         ASN1_VALUE *o = ASN1_item_d2i(NULL, &b, len, i);
 
         if (o != NULL) {
-            BIO *bio = BIO_new(BIO_s_null());
-            if (bio != NULL) {
-                ASN1_item_print(bio, o, 4, i, pctx);
-                BIO_free(bio);
+            /*
+             * Don't print excessively long output to prevent spurious fuzzer
+             * timeouts.
+             */
+            if (b - buf < 10000) {
+                BIO *bio = BIO_new(BIO_s_null());
+                if (bio != NULL) {
+                    ASN1_item_print(bio, o, 4, i, pctx);
+                    BIO_free(bio);
+                }
+            }
+            if (ASN1_item_i2d(o, &der, i) > 0) {
+                OPENSSL_free(der);
             }
-            ASN1_item_i2d(o, &der, i);
-            OPENSSL_free(der);
             ASN1_item_free(o, i);
         }
     }