From 84b6338e72e212cfb0fee745eebdefed52ecb25b Mon Sep 17 00:00:00 2001 From: truckman Date: Fri, 20 May 2016 06:02:44 +0000 Subject: [PATCH] MFC r299524 Use strlcpy() instead of strncpy() when copying the encoding value to ensure that the destination is NUL terminated. Length truncation of one more character should not be an issue since encoding values that long are not supported by libc. The destination string is treated as a NUL terminated string, but it is only passed to strcmp() for comparison to a set of shorter, fixed length strings, so this is not a serious problem. Reported by: Coverity CID: 974769 git-svn-id: svn://svn.freebsd.org/base/stable/10@300265 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.bin/mklocale/yacc.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/mklocale/yacc.y b/usr.bin/mklocale/yacc.y index c5304c9ef..01f9f493a 100644 --- a/usr.bin/mklocale/yacc.y +++ b/usr.bin/mklocale/yacc.y @@ -123,7 +123,7 @@ entry : ENCODING STRING strcmp($2, "BIG5") && strcmp($2, "MSKanji")) warnx("ENCODING %s is not supported by libc", $2); - strncpy(new_locale.encoding, $2, + strlcpy(new_locale.encoding, $2, sizeof(new_locale.encoding)); } | VARIABLE { new_locale.variable_len = strlen($1) + 1; -- 2.45.0