strcoll(1): Fix named locale case where conversion fails
authorJohn Marino <draco@marino.st>
Sun, 2 Aug 2015 11:19:16 +0000 (13:19 +0200)
committerJohn Marino <draco@marino.st>
Sun, 2 Aug 2015 11:28:42 +0000 (13:28 +0200)
commitbea37db929b4bc021536360b9878c6bde0650f09
treec69e21441b9bf6ca4002c9579412ea80e21c3a60
parent6ca67e7ac33c027093ecaadb5ce4732a9e35bcbf
strcoll(1): Fix named locale case where conversion fails

When strcoll is used with a locale other than C/POSIX, it uses the
mbsrtowcs_l(1) function which can alter the src pointer upon failure.
If that happens in the current implementation of strcoll, a null pointer
is send to strcmp (resulting in wrong answer) and it will change the s
or s2 argument of strcoll(1), which is not behavior expected by the POSIX
standard.

Using a copy of the s and s2 arguments prevents this situation.  Note that
Illumos, which which the source came, still has this vulnerability.

Reported by: Romick (YRabbit) on IRC
lib/libc/string/strcoll.c