=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/term_ascii.c,v retrieving revision 1.37 retrieving revision 1.38 diff -c -r1.37 -r1.38 *** src/usr.bin/mandoc/term_ascii.c 2015/10/13 22:57:49 1.37 --- src/usr.bin/mandoc/term_ascii.c 2015/11/12 21:49:29 1.38 *************** *** 1,4 **** ! /* $OpenBSD: term_ascii.c,v 1.37 2015/10/13 22:57:49 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2014, 2015 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: term_ascii.c,v 1.38 2015/11/12 21:49:29 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2014, 2015 Ingo Schwarze *************** *** 77,84 **** p->width = ascii_width; if (TERMENC_ASCII != enc) { v = TERMENC_LOCALE == enc ? ! setlocale(LC_ALL, "") : setlocale(LC_CTYPE, "en_US.UTF-8"); if (NULL != v && MB_CUR_MAX > 1) { p->enc = enc; --- 77,92 ---- 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_CTYPE, "") : setlocale(LC_CTYPE, "en_US.UTF-8"); if (NULL != v && MB_CUR_MAX > 1) { p->enc = enc;