diff options
author | Jiasheng Jiang <jiasheng@iscas.ac.cn> | 2022-06-15 16:07:12 +0800 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-06-17 08:51:11 +0200 |
commit | 8547cd6790881cbba0f20aa4ce048243065a24bf (patch) | |
tree | d04500b9eb9d2948d4865d9ffb8a69f3acdc102a /crypto/asn1 | |
parent | 93ed4b5fb40a8ece9d9c67041c4187d63dbfbd51 (diff) |
crypto/asn1/a_time.c: Add check for OPENSSL_malloc
As the potential failure of the OPENSSL_malloc(),
timestamp_tm could be NULL and be used in ASN1_TIME_to_tm()
without check.
Therefore, it should be better to check the return value of
OPENSSL_malloc() and return error if fails.
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18575)
Diffstat (limited to 'crypto/asn1')
-rw-r--r-- | crypto/asn1/a_time.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c index 4b9a0641fb..a92cdaa89e 100644 --- a/crypto/asn1/a_time.c +++ b/crypto/asn1/a_time.c @@ -618,7 +618,10 @@ time_t asn1_string_to_time_t(const char *asn1_string) } timestamp_tm = OPENSSL_malloc(sizeof(*timestamp_tm)); - + if (timestamp_tm == NULL) { + ASN1_TIME_free(timestamp_asn1); + return -1; + } if (!(ASN1_TIME_to_tm(timestamp_asn1, timestamp_tm))) { OPENSSL_free(timestamp_tm); ASN1_TIME_free(timestamp_asn1); |