summaryrefslogtreecommitdiffstats
path: root/term_ascii.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-11-12 21:50:03 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-11-12 21:50:03 +0000
commitc72fb33264580ff703ba623bf3c13a5ff1babfea (patch)
treedf47e9da77097d16dfb8dc4af19ba0026030ffed /term_ascii.c
parentede30926eaf7a3ef54ed114e4d481fa59bf9f90d (diff)
downloadmandoc-c72fb33264580ff703ba623bf3c13a5ff1babfea.tar.gz
Never use LC_ALL. On the one hand, it can cause misformatting.
On the other hand, it is a security risk because it might cause buffer overflows. Use LC_CTYPE only, that's all we need.
Diffstat (limited to 'term_ascii.c')
-rw-r--r--term_ascii.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/term_ascii.c b/term_ascii.c
index 1d587c63..2f67eb88 100644
--- a/term_ascii.c
+++ b/term_ascii.c
@@ -88,8 +88,16 @@ ascii_init(enum termenc enc, const struct manoutput *outopts)
#if HAVE_WCHAR
if (TERMENC_ASCII != enc) {
+
+ /*
+ * Do not change any of this to LC_ALL. It might break
+ * the formatting by subtly changing the behaviour of
+ * various functions, for example strftime(3). As a
+ * worst case, it might even cause buffer overflows.
+ */
+
v = TERMENC_LOCALE == enc ?
- setlocale(LC_ALL, "") :
+ setlocale(LC_CTYPE, "") :
setlocale(LC_CTYPE, "en_US.UTF-8");
if (NULL != v && MB_CUR_MAX > 1) {
p->enc = enc;