From: Jiasheng Jiang Date: Fri, 17 Jun 2022 08:57:15 +0000 (+0800) Subject: test/evp_test.c: Add check for OPENSSL_strdup X-Git-Tag: openssl-3.2.0-alpha1~2499 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5203a8dfdc209f05c7dbd9c1e5208743fcaa6752;p=thirdparty%2Fopenssl.git 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 Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/18592) --- diff --git a/test/evp_test.c b/test/evp_test.c index 5d51c47ef5c..c7f76df3598 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -1256,7 +1256,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; } @@ -1268,9 +1268,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)