Skip to content

Commit

Permalink
Don't print excessively long ASN1 items in fuzzer
Browse files Browse the repository at this point in the history
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 #23640)

(cherry picked from commit 4a6f70c)
  • Loading branch information
mattcaswell committed Feb 21, 2024
1 parent 88038f5 commit 878d319
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions fuzz/asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 878d319

Please sign in to comment.