r2437: implemented a suggestion from abartlet that if we cannot convert
authorAndrew Tridgell <tridge@samba.org>
Mon, 20 Sep 2004 07:31:54 +0000 (07:31 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:58:53 +0000 (12:58 -0500)
strings to UTF16 in StrCaseCmp() that we fall back to a simpler
comparison.
(This used to be commit 2fa6ab9fe30aeacd7b1421fd83c409acf31c98aa)

source4/lib/util_str.c

index 961bdb8084f057ab5613d6368e4b2d02888b07a4..3fe6fd1cc02af720787fffba0422d18228de1428 100644 (file)
@@ -123,8 +123,11 @@ static int StrCaseCmp_slow(const char *s1, const char *s2)
        smb_ucs2_t *u1, *u2;
        int ret;
 
-       convert_string_allocate(CH_UNIX, CH_UTF16, s1, strlen(s1)+1, &u1);
-       convert_string_allocate(CH_UNIX, CH_UTF16, s2, strlen(s2)+1, &u2);
+       if (convert_string_allocate(CH_UNIX, CH_UTF16, s1, strlen(s1)+1, &u1) == -1 ||
+           convert_string_allocate(CH_UNIX, CH_UTF16, s2, strlen(s2)+1, &u2) == -1) {
+               /* fallback to a simple comparison */
+               return strcasecmp(s1, s2);
+       }
 
        ret = strcasecmp_w(u1, u2);