Second part of fix for bug 8310 - toupper_ascii() is broken on big-endian systems.
authorJeremy Allison <jra@samba.org>
Tue, 19 Jul 2011 20:35:45 +0000 (13:35 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 19 Jul 2011 21:48:05 +0000 (23:48 +0200)
Re-add:
smb_ucs2_t toupper_w(smb_ucs2_t v);

and ensure it is called whenever we are operating on smb_ucs2_t
variables. I'd like to make the definition of smb_ucs2_t incompatible
with int and codepoint_t so they can't be mixed, but that's a patch
for another time.

Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Tue Jul 19 23:48:05 CEST 2011 on sn-devel-104

lib/util/charset/charset.h
lib/util/charset/util_unistr_w.c
source3/lib/charcnv.c
source3/lib/ms_fnmatch.c

index 08bb4533d22915e8466f3abf7009241bdc9d43cc..ce297d0ddd78b50d2d5555fc5e0e638cfe41a7d7 100644 (file)
@@ -257,6 +257,7 @@ int strcmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b);
 int strcasecmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b);
 int strncasecmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b, size_t len);
 int strcmp_wa(const smb_ucs2_t *a, const char *b);
+smb_ucs2_t toupper_w(smb_ucs2_t v);
 
 /*
  *   Define stub for charset module which implements 8-bit encoding with gaps.
index fc6d3747bd2670cff1e5b2c0fd116cfd30ee163b..7e0ece383f209021086d5382d7ccc4ebc4c7456b 100644 (file)
@@ -252,3 +252,14 @@ int strcmp_wa(const smb_ucs2_t *a, const char *b)
        }
        return (*(COPY_UCS2_CHAR(&cp,a)) - UCS2_CHAR(*b));
 }
+
+smb_ucs2_t toupper_w(smb_ucs2_t v)
+{
+       smb_ucs2_t ret;
+       /* LE to native. */
+       codepoint_t cp = SVAL(&v,0);
+       cp = toupper_m(cp);
+       /* native to LE. */
+       SSVAL(&ret,0,cp);
+       return ret;
+}
index 17e836dfe0f35c93094e3defdd0e5d8f816aaea9..7d7058cbb04d646991caff8f599cb2b771e27440 100644 (file)
@@ -287,7 +287,7 @@ static size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_
                   terminated if STR_TERMINATE isn't set. */
 
                for (i = 0; i < (ret / 2) && i < (dest_len / 2) && dest_ucs2[i]; i++) {
-                       smb_ucs2_t v = toupper_m(dest_ucs2[i]);
+                       smb_ucs2_t v = toupper_w(dest_ucs2[i]);
                        if (v != dest_ucs2[i]) {
                                dest_ucs2[i] = v;
                        }
index f02354bfd7d68d874dcc565e990c6f0f1f46879a..e32d094a6b22c8567bcd33f54652984d21fc6890 100644 (file)
@@ -129,7 +129,7 @@ static int ms_fnmatch_core(const smb_ucs2_t *p, const smb_ucs2_t *n,
                                if (is_case_sensitive) {
                                        return -1;
                                }
-                               if (toupper_m(c) != toupper_m(*n)) {
+                               if (toupper_w(c) != toupper_w(*n)) {
                                        return -1;
                                }
                        }