From 5e56f4587de2f2e06c079272fa4d6712d56dbcf0 Mon Sep 17 00:00:00 2001 From: Pauli Date: Tue, 29 Jun 2021 08:26:11 +1000 Subject: [PATCH] evp: fix coverity 1473380 Copy into fixed size buffer (STRING_OVERFLOW) Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15943) --- crypto/evp/ctrl_params_translate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto/evp/ctrl_params_translate.c b/crypto/evp/ctrl_params_translate.c index 6998dcc6fc1..c532e57f8f6 100644 --- a/crypto/evp/ctrl_params_translate.c +++ b/crypto/evp/ctrl_params_translate.c @@ -1353,7 +1353,9 @@ static int fix_rsa_pss_saltlen(enum state state, if (i == OSSL_NELEM(str_value_map)) { BIO_snprintf(ctx->name_buf, sizeof(ctx->name_buf), "%d", ctx->p1); } else { - strcpy(ctx->name_buf, str_value_map[i].ptr); + strncpy(ctx->name_buf, str_value_map[i].ptr, sizeof(ctx->name_buf)); + /* This won't truncate but it will quiet static analysers */ + ctx->name_buf[sizeof(ctx->name_buf) - 1] = '\0'; } ctx->p2 = ctx->name_buf; ctx->p1 = strlen(ctx->p2); -- 2.47.3