Fix compile warning with GCC 11.
authorJuergen Christ <jchrist@linux.ibm.com>
Mon, 5 Jul 2021 07:48:53 +0000 (09:48 +0200)
committerTomas Mraz <tomas@openssl.org>
Thu, 8 Jul 2021 08:34:55 +0000 (10:34 +0200)
commitdaf4b2437f38bd104400517cf8ff2c8121813b1a
tree7f60d7d359f82cf8bdab0c464d275d1d827191c1
parent0588778f5ef5c5840e00879a1f62775e4c7a2f17
Fix compile warning with GCC 11.

When configured with strict warnings, GCC 11 complains about a possible
stringop-translation:

Config:

/usr/bin/perl ./Configure enable-asan enable-ubsan enable-zlib-dynamic \
enable-unit-test enable-md2 enable-rc5 enable-buildtest-c++ \
enable-weak-ssl-ciphers enable-ssl3 enable-ssl3-method enable-fips -w \
--strict-warnings

Warning:

crypto/evp/ctrl_params_translate.c: In function 'fix_rsa_pss_saltlen':
crypto/evp/ctrl_params_translate.c:1356:13: error: 'strncpy' specified bound 50 equals destination size [-Werror=stringop-truncation]
 1356 |             strncpy(ctx->name_buf, str_value_map[i].ptr, sizeof(ctx->name_buf));
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix by copying one byte less than the buffer size.  We anyway overwrite the
last byte.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15993)
crypto/evp/ctrl_params_translate.c