summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/term_ascii.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2015-11-12 21:49:30 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2015-11-12 21:49:30 +0000
commit13305bb994459b31239ff394cad05a300b8463a2 (patch)
tree7dc4dc36cc4b77dd3da96f93b16f7adf1cf09f0e /usr.bin/mandoc/term_ascii.c
parentf6b08f58b13dcf6b4d1c5bbf3ba5b17a31d0f4ba (diff)
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 'usr.bin/mandoc/term_ascii.c')
-rw-r--r--usr.bin/mandoc/term_ascii.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.bin/mandoc/term_ascii.c b/usr.bin/mandoc/term_ascii.c
index 3fcc825ea85..bf8a0a555ea 100644
--- a/usr.bin/mandoc/term_ascii.c
+++ b/usr.bin/mandoc/term_ascii.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term_ascii.c,v 1.37 2015/10/13 22:57:49 schwarze Exp $ */
+/* $OpenBSD: term_ascii.c,v 1.38 2015/11/12 21:49:29 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -77,8 +77,16 @@ ascii_init(enum termenc enc, const struct manoutput *outopts)
p->width = ascii_width;
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;