diff options
author | Matt Caswell <matt@openssl.org> | 2024-02-20 15:11:26 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2024-02-21 16:49:25 +0000 |
commit | 878d31954738369c35cbafbaa65e9201e9fc6d4b (patch) | |
tree | daba294039d55f976d96c68be2c3a6bc4607b03a /fuzz | |
parent | 88038f5aec58b138d45f33a745b732e6510eba33 (diff) |
Don't print excessively long ASN1 items in fuzzer
Prevent spurious fuzzer timeouts by not printing ASN1 which is excessively
long.
This fixes a false positive encountered by OSS-Fuzz.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23640)
(cherry picked from commit 4a6f70c03182b421d326831532edca32bcdb3fb1)
Diffstat (limited to 'fuzz')
-rw-r--r-- | fuzz/asn1.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/fuzz/asn1.c b/fuzz/asn1.c index ee602a08a3..d55554b7fd 100644 --- a/fuzz/asn1.c +++ b/fuzz/asn1.c @@ -312,10 +312,16 @@ 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); |