upstream: AIX reports the CODESET as "ISO8859-1" in the POSIX locale.

Treating that as a safe encoding is OK because even when other systems return
that string for real ISO8859-1, it is still safe in the sense that it is
ASCII-compatible and stateless.

Issue reported by Val dot Baranov at duke dot edu.  Additional
information provided by Michael dot Felt at felt dot demon dot nl.
Tested by Michael Felt on AIX 6.1 and by Val Baranov on AIX 7.1.
Tweak and OK djm@.

OpenBSD-Commit-ID: 36f1210e0b229817d10eb490d6038f507b8256a7
This commit is contained in:
schwarze@openbsd.org 2018-08-21 13:56:27 +00:00 committed by Damien Miller
parent bc44ee088a
commit b8ae02a289
1 changed files with 9 additions and 4 deletions

13
utf8.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: utf8.c,v 1.7 2017/05/31 09:15:42 deraadt Exp $ */ /* $OpenBSD: utf8.c,v 1.8 2018/08/21 13:56:27 schwarze Exp $ */
/* /*
* Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
* *
@ -53,6 +53,8 @@ static int vasnmprintf(char **, size_t, int *, const char *, va_list);
* For state-dependent encodings, recovery is impossible. * For state-dependent encodings, recovery is impossible.
* For arbitrary encodings, replacement of non-printable * For arbitrary encodings, replacement of non-printable
* characters would be non-trivial and too fragile. * characters would be non-trivial and too fragile.
* The comments indicate what nl_langinfo(CODESET)
* returns for US-ASCII on various operating systems.
*/ */
static int static int
@ -60,9 +62,12 @@ dangerous_locale(void) {
char *loc; char *loc;
loc = nl_langinfo(CODESET); loc = nl_langinfo(CODESET);
return strcmp(loc, "US-ASCII") != 0 && strcmp(loc, "UTF-8") != 0 && return strcmp(loc, "UTF-8") != 0 &&
strcmp(loc, "ANSI_X3.4-1968") != 0 && strcmp(loc, "646") != 0 && strcmp(loc, "US-ASCII") != 0 && /* OpenBSD */
strcmp(loc, "") != 0; strcmp(loc, "ANSI_X3.4-1968") != 0 && /* Linux */
strcmp(loc, "ISO8859-1") != 0 && /* AIX */
strcmp(loc, "646") != 0 && /* Solaris, NetBSD */
strcmp(loc, "") != 0; /* Solaris 6 */
} }
static int static int