apps/ocsp: Add check for OPENSSL_strdup
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Thu, 10 Feb 2022 07:41:40 +0000 (15:41 +0800)
committerTomas Mraz <tomas@openssl.org>
Thu, 17 Feb 2022 10:23:03 +0000 (11:23 +0100)
commit8f084b43803d53e15d83ed130210f026f84679ff
tree358c2a8cbe03d819d23c3cd792c9c27a1c246b88
parent0c5905581e9d1d79d62cac56a0e3c2ed487afecf
apps/ocsp: Add check for OPENSSL_strdup

Just assert 'bn' to be non-NULL is not enough.
The check for 'itmp' is still needed.
If 'bn' is 0, the 'itmp' is assigned by OPENSSL_strdup().
Since OPENSSL_strdup() may fail because of the lack of memory,
the 'itmp' will be NULL and be an valid parameter hashed in
TXT_DB_get_by_index(), returning a wrong result.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17677)
apps/ocsp.c