diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-11-12 21:50:03 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-11-12 21:50:03 +0000 |
commit | d42999c4e1db433908ffe9176d21f648619efe03 (patch) | |
tree | 92dafeeb006db61615d144410e6406122a85cce9 | |
parent | 0999c24db236cf37a583c4211b9c6da75a9bd3fc (diff) | |
download | mandoc-d42999c4e1db433908ffe9176d21f648619efe03.tar.gz mandoc-d42999c4e1db433908ffe9176d21f648619efe03.tar.zst mandoc-d42999c4e1db433908ffe9176d21f648619efe03.zip |
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.
-rw-r--r-- | term_ascii.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/term_ascii.c b/term_ascii.c index c4633b3d..7215a597 100644 --- a/term_ascii.c +++ b/term_ascii.c @@ -1,4 +1,4 @@ -/* $Id: term_ascii.c,v 1.51 2015/10/13 22:59:54 schwarze Exp $ */ +/* $Id: term_ascii.c,v 1.52 2015/11/12 21:50:03 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -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; |