summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2011-07-19 13:08:31 -0700
committerKarolin Seeger <kseeger@samba.org>2011-07-26 21:54:36 +0200
commit669c6b00753487955a03312f5aab3a455b04df61 (patch)
treebe9a1cd87f92a46a39818ce8fbace41a7c1e20bf
parent9deadb668d82a0b608123c3940075e92ea93c009 (diff)
downloadsamba-669c6b00753487955a03312f5aab3a455b04df61.tar.gz
samba-669c6b00753487955a03312f5aab3a455b04df61.tar.xz
samba-669c6b00753487955a03312f5aab3a455b04df61.zip
Second part of fix for bug 8310 - toupper_ascii() is broken on big-endian systems.
Re-add: smb_ucs2_t toupper_w(smb_ucs2_t v); bool isupper_w(smb_ucs2_t v); smb_ucs2_t tolower_w(smb_ucs2_t v); bool islower_w(smb_ucs2_t v); and ensure they are 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. (cherry picked from commit bdc078a81e49bce3b51560a75984e0306c387573)
-rw-r--r--source3/include/proto.h4
-rw-r--r--source3/lib/charcnv.c2
-rw-r--r--source3/lib/ms_fnmatch.c2
-rw-r--r--source3/lib/util_str.c4
-rw-r--r--source3/lib/util_unistr.c46
5 files changed, 48 insertions, 10 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index cf418849d6b..393dd77a36f 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1051,6 +1051,10 @@ int strcmp_wa(const smb_ucs2_t *a, const char *b);
int strncmp_wa(const smb_ucs2_t *a, const char *b, size_t len);
smb_ucs2_t *strpbrk_wa(const smb_ucs2_t *s, const char *p);
smb_ucs2_t *strstr_wa(const smb_ucs2_t *s, const char *ins);
+smb_ucs2_t toupper_w(smb_ucs2_t v);
+bool isupper_w(smb_ucs2_t v);
+smb_ucs2_t tolower_w(smb_ucs2_t v);
+bool islower_w(smb_ucs2_t v);
/* The following definitions come from lib/version.c */
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index fd6cefe7e5e..d3f65ca4e24 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -1132,7 +1132,7 @@ size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_
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;
}
diff --git a/source3/lib/ms_fnmatch.c b/source3/lib/ms_fnmatch.c
index 31c66953a96..bff73829407 100644
--- a/source3/lib/ms_fnmatch.c
+++ b/source3/lib/ms_fnmatch.c
@@ -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;
}
}
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 733db27b363..470152814e3 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -460,7 +460,7 @@ bool strhasupper(const char *s)
}
for(p = tmp; *p != 0; p++) {
- if(isupper_m(*p)) {
+ if(isupper_w(*p)) {
break;
}
}
@@ -485,7 +485,7 @@ bool strhaslower(const char *s)
}
for(p = tmp; *p != 0; p++) {
- if(islower_m(*p)) {
+ if(islower_w(*p)) {
break;
}
}
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c
index d8a360dfcc3..b8bece1e817 100644
--- a/source3/lib/util_unistr.c
+++ b/source3/lib/util_unistr.c
@@ -254,7 +254,7 @@ bool strlower_w(smb_ucs2_t *s)
bool ret = False;
while (*(COPY_UCS2_CHAR(&cp,s))) {
- smb_ucs2_t v = tolower_m(cp);
+ smb_ucs2_t v = tolower_w(cp);
if (v != cp) {
COPY_UCS2_CHAR(s,&v);
ret = True;
@@ -276,7 +276,7 @@ bool strupper_w(smb_ucs2_t *s)
smb_ucs2_t cp;
bool ret = False;
while (*(COPY_UCS2_CHAR(&cp,s))) {
- smb_ucs2_t v = toupper_m(cp);
+ smb_ucs2_t v = toupper_w(cp);
if (v != cp) {
COPY_UCS2_CHAR(s,&v);
ret = True;
@@ -334,11 +334,11 @@ int strcasecmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b)
{
smb_ucs2_t cpa, cpb;
- while ((*COPY_UCS2_CHAR(&cpb,b)) && toupper_m(*(COPY_UCS2_CHAR(&cpa,a))) == toupper_m(cpb)) {
+ while ((*COPY_UCS2_CHAR(&cpb,b)) && toupper_w(*(COPY_UCS2_CHAR(&cpa,a))) == toupper_w(cpb)) {
a++;
b++;
}
- return (tolower_m(*(COPY_UCS2_CHAR(&cpa,a))) - tolower_m(*(COPY_UCS2_CHAR(&cpb,b))));
+ return (tolower_w(*(COPY_UCS2_CHAR(&cpa,a))) - tolower_w(*(COPY_UCS2_CHAR(&cpb,b))));
}
/*******************************************************************
@@ -350,12 +350,12 @@ int strncasecmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b, size_t len)
smb_ucs2_t cpa, cpb;
size_t n = 0;
- while ((n < len) && *COPY_UCS2_CHAR(&cpb,b) && (toupper_m(*(COPY_UCS2_CHAR(&cpa,a))) == toupper_m(cpb))) {
+ while ((n < len) && *COPY_UCS2_CHAR(&cpb,b) && (toupper_w(*(COPY_UCS2_CHAR(&cpa,a))) == toupper_w(cpb))) {
a++;
b++;
n++;
}
- return (len - n)?(tolower_m(*(COPY_UCS2_CHAR(&cpa,a))) - tolower_m(*(COPY_UCS2_CHAR(&cpb,b)))):0;
+ return (len - n)?(tolower_w(*(COPY_UCS2_CHAR(&cpa,a))) - tolower_w(*(COPY_UCS2_CHAR(&cpb,b)))):0;
}
/*******************************************************************
@@ -606,3 +606,37 @@ smb_ucs2_t *strstr_wa(const smb_ucs2_t *s, const char *ins)
return NULL;
}
+
+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;
+}
+
+bool isupper_w(smb_ucs2_t v)
+{
+ codepoint_t cp = SVAL(&v,0);
+ return isupper_m(cp);
+}
+
+smb_ucs2_t tolower_w(smb_ucs2_t v)
+{
+ smb_ucs2_t ret;
+ /* LE to native. */
+ codepoint_t cp = SVAL(&v,0);
+ cp = tolower_m(cp);
+ /* native to LE. */
+ SSVAL(&ret,0,cp);
+ return ret;
+}
+
+bool islower_w(smb_ucs2_t v)
+{
+ codepoint_t cp = SVAL(&v,0);
+ return islower_m(cp);
+}