提交 d43597c7 编写于 作者: J Jiasheng Jiang 提交者: Dr. Matthias St. Pierre

fuzz/asn1.c: Add missing check for BIO_new

Since the BIO_new may fail, the 'bio' could be NULL pointer and be used.
Therefore, it should be better to check it and skip the print if fails.
Signed-off-by: NJiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: NTomas Mraz <tomas@openssl.org>
Reviewed-by: NPaul Dale <pauli@openssl.org>
Reviewed-by: NMatthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/17690)
上级 78c5f126
......@@ -218,8 +218,10 @@ static ASN1_PCTX *pctx;
int len2; \
BIO *bio = BIO_new(BIO_s_null()); \
\
PRINT(bio, type); \
BIO_free(bio); \
if (bio != NULL) { \
PRINT(bio, type); \
BIO_free(bio); \
} \
len2 = I2D(type, &der); \
if (len2 != 0) {} \
OPENSSL_free(der); \
......@@ -235,8 +237,10 @@ static ASN1_PCTX *pctx;
if (type != NULL) { \
BIO *bio = BIO_new(BIO_s_null()); \
\
PRINT(bio, type, 0); \
BIO_free(bio); \
if (bio != NULL) { \
PRINT(bio, type, 0); \
BIO_free(bio); \
} \
I2D(type, &der); \
OPENSSL_free(der); \
TYPE ## _free(type); \
......@@ -251,8 +255,10 @@ static ASN1_PCTX *pctx;
if (type != NULL) { \
BIO *bio = BIO_new(BIO_s_null()); \
\
PRINT(bio, type, 0, pctx); \
BIO_free(bio); \
if (bio != NULL) { \
PRINT(bio, type, 0, pctx); \
BIO_free(bio); \
} \
I2D(type, &der); \
OPENSSL_free(der); \
TYPE ## _free(type); \
......@@ -307,9 +313,10 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
if (o != NULL) {
BIO *bio = BIO_new(BIO_s_null());
ASN1_item_print(bio, o, 4, i, pctx);
BIO_free(bio);
if (bio != NULL) {
ASN1_item_print(bio, o, 4, i, pctx);
BIO_free(bio);
}
ASN1_item_i2d(o, &der, i);
OPENSSL_free(der);
ASN1_item_free(o, i);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册