testsuite error on Solaris 2.6

Ingo Schwarze schwarze at usta.de
Sun Apr 2 23:43:13 AEST 2017


Hi,

Tom G. Christensen wrote on Fri, Mar 31, 2017 at 09:30:10PM +0200:
> On 27/03/17 17:06, Tom G. Christensen wrote:

>> I'm seeing an error in the testsuite on Solaris 2.6:
>> test_utf8: ........................
>> regress/unittests/utf8/tests.c:48 test #25 "c_esc"
>> ASSERT_INT_EQ(len, wantlen) failed:
>>          len = -1
>>      wantlen = 5
>> 
>> 
>> It seems this might be related to the fact that on Solaris < 7
>> nl_langinfo(CODESET) returns an empty string when the codeset is ASCII.
>> 
>> To verify I put together a small testprogram that does a setlocale
>> followed by nl_langinfo(CODESET) and for the 'C' locale it returns an
>> empty string while 'da' returns ISO8859-1 as expected.

> I worked some more on this and comparing locales and their codesets
> between Solaris 2.6 and 7 I'm reasonably sure that an empty codeset
> value means ascii on Solaris 2.6.

I'm not quite sure how relevant Solaris 2.6 still is, but i dimly
remeber having seen systems where nl_langinfo(3) returns "" for
ASCII before, though i have forgotten which ones.  

> So to ensure proper operation and get rid of the error in the testsuite
> I've added "" as a valid alias for ascii in dangerous_locales().
> With this change in place the testsuite runs with no errors.

That would be the following patch.  I don't see any downside.
A system where nl_codeset(3) would return "" for some non-ASCII
and non-UTF-8 locale would probably cause you worse grief than
sftp(1) or scp(1) potentially screwing up your terminal settings.

OK?
  Ingo


Index: utf8.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/utf8.c,v
retrieving revision 1.5
diff -u -p -r1.5 utf8.c
--- utf8.c	19 Feb 2017 00:10:57 -0000	1.5
+++ utf8.c	2 Apr 2017 13:35:38 -0000
@@ -51,8 +51,8 @@ dangerous_locale(void) {
 	char	*loc;
 
 	loc = nl_langinfo(CODESET);
-	return strcmp(loc, "US-ASCII") != 0 && strcmp(loc, "UTF-8") != 0 &&
-	    strcmp(loc, "ANSI_X3.4-1968") != 0;
+	return *loc != '\0' && strcmp(loc, "US-ASCII") != 0 &&
+	    strcmp(loc, "UTF-8") != 0 && strcmp(loc, "ANSI_X3.4-1968") != 0;
 }
 
 static int


More information about the openssh-unix-dev mailing list