summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2016-05-20 06:02:44 +0000
committertruckman <truckman@FreeBSD.org>2016-05-20 06:02:44 +0000
commit5144a68f04dc5f529b959e282b222666caea04d7 (patch)
treef7a0572213895be442124410fb7de7129a0a5a0c /usr.bin
parent9be0db2aad5d5e479d2dc12e248ddbbc08ca57d1 (diff)
downloadFreeBSD-src-5144a68f04dc5f529b959e282b222666caea04d7.zip
FreeBSD-src-5144a68f04dc5f529b959e282b222666caea04d7.tar.gz
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
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mklocale/yacc.y2
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.bin/mklocale/yacc.y b/usr.bin/mklocale/yacc.y
index c5304c9..01f9f49 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;
OpenPOWER on IntegriCloud