summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiasheng Jiang <jiasheng@iscas.ac.cn>2022-06-17 16:57:15 +0800
committerPauli <pauli@openssl.org>2022-06-22 17:01:00 +1000
commit6408e7cf8acad6f816268f2f62e17c8c0985c1c3 (patch)
tree312c3b21b7d324b99300bf34038c7b53fb1bcbc3
parenta58978f1bf44706f88395d9011a7be405a0c6e4b (diff)
test/evp_test.c: Add check for OPENSSL_strdup
As the potential failure of the OPENSSL_strdup(), it should be better to check the return value and return error if fails. Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18592) (cherry picked from commit 5203a8dfdc209f05c7dbd9c1e5208743fcaa6752)
-rw-r--r--test/evp_test.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/test/evp_test.c b/test/evp_test.c
index 0ba8164db0..a3ab460105 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -1236,7 +1236,7 @@ static int mac_test_parse(EVP_TEST *t,
return parse_bin(value, &mdata->salt, &mdata->salt_len);
if (strcmp(keyword, "Algorithm") == 0) {
mdata->alg = OPENSSL_strdup(value);
- if (!mdata->alg)
+ if (mdata->alg == NULL)
return -1;
return 1;
}
@@ -1248,9 +1248,13 @@ static int mac_test_parse(EVP_TEST *t,
return mdata->xof = 1;
if (strcmp(keyword, "NoReinit") == 0)
return mdata->no_reinit = 1;
- if (strcmp(keyword, "Ctrl") == 0)
- return sk_OPENSSL_STRING_push(mdata->controls,
- OPENSSL_strdup(value)) != 0;
+ if (strcmp(keyword, "Ctrl") == 0) {
+ char *data = OPENSSL_strdup(value);
+
+ if (data == NULL)
+ return -1;
+ return sk_OPENSSL_STRING_push(mdata->controls, data) != 0;
+ }
if (strcmp(keyword, "OutputSize") == 0) {
mdata->output_size = atoi(value);
if (mdata->output_size < 0)