fuzz/asn1.c: Add check for ASN1_item_i2d

As the potential failure of the ASN1_item_i2d,
it should be better to check the return value.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18647)
This commit is contained in:
Jiasheng Jiang 2022-06-24 15:35:05 +08:00 committed by Tomas Mraz
parent 28adea9597
commit 1cb35ce06a

View File

@ -317,8 +317,9 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
ASN1_item_print(bio, o, 4, i, pctx);
BIO_free(bio);
}
ASN1_item_i2d(o, &der, i);
OPENSSL_free(der);
if (ASN1_item_i2d(o, &der, i) > 0) {
OPENSSL_free(der);
}
ASN1_item_free(o, i);
}
}