lib: strings: Fix the behavior of strcasecmp_m_handle() in the face of bad conversions.
authorJeremy Allison <jra@samba.org>
Sat, 2 Aug 2014 04:29:21 +0000 (21:29 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 5 Aug 2014 23:05:14 +0000 (01:05 +0200)
commit9380478a0b292bcb0c11987a88803a37a064d618
tree06269e2e83e16e71140bdcb01c98aae978ca8fe7
parent88f6a6c188b8e43f710c50a9c1f88af660772e3d
lib: strings: Fix the behavior of strcasecmp_m_handle() in the face of bad conversions.

When either string has a bad conversion, we fall back to
doing raw ascii byte comparisons using strcasecmp().

The problem is we've already stepped past the character
that failed the conversion, so we're not re-testing those
characters for comparison. This can have the effect of
causing strcasecmp_m_handle() to report that two strings
are identical when they are not, if the failed conversion
takes place at the end of the string.

The correct behavior is to step back to the point of
the string(s) that failed the conversion, and continue
the test from there.

Found by <lev@zadarastorage.com> when investigating bug
10716 - smbd constantly crashes when filename contains non-ascii character.

Given the normal character set of utf-8, and an on
disk filename of ISO-8859-1 of file-é on disk hex
value: 66 69 6c 65 2d e9, an incoming open given the
correct utf8 name of file-é will collide when it
should not.

Fixes:

Bug 10716 - smbd constantly crashes when filename contains non-ascii character

https://bugzilla.samba.org/show_bug.cgi?id=10716

Signed-off-by: Jeremy Allison <jra@samba.org>
lib/util/charset/util_str.c