[SCM] Samba Shared Repository - branch v3-6-test updated
Karolin Seeger
kseeger at samba.org
Thu Jul 21 12:16:07 MDT 2011
The branch, v3-6-test has been updated
via bdc078a Second part of fix for bug 8310 - toupper_ascii() is broken on big-endian systems.
via 5b6a341 First part of fix for bug 8310 - toupper_ascii() is broken on big-endian systems
from c5b272a Fix bug #8307 - brl_close_fnum does not call SMB_VFS_BRL_UNLOCK_WINDOWS on all locks
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test
- Log -----------------------------------------------------------------
commit bdc078a81e49bce3b51560a75984e0306c387573
Author: Jeremy Allison <jra at samba.org>
Date: Tue Jul 19 13:08:31 2011 -0700
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.
commit 5b6a34128a0e0bc33c255dc53c9fb9fd8e6d34d8
Author: Jeremy Allison <jra at samba.org>
Date: Tue Jul 19 12:21:23 2011 -0700
First part of fix for bug 8310 - toupper_ascii() is broken on big-endian systems
Remove
int toupper_ascii(int c);
int tolower_ascii(int c);
int isupper_ascii(int c);
int islower_ascii(int c);
and replace with their _m equivalents, as they are identical.
-----------------------------------------------------------------------
Summary of changes:
source3/auth/pass_check.c | 4 +-
source3/client/clitar.c | 2 +-
source3/include/proto.h | 8 +++---
source3/lib/charcnv.c | 2 +-
source3/lib/ms_fnmatch.c | 2 +-
source3/lib/username.c | 4 +-
source3/lib/util_str.c | 8 +++---
source3/lib/util_unistr.c | 60 ++++++++++++++++++++-----------------------
source3/param/loadparm.c | 6 ++--
source3/passdb/passdb.c | 8 +++---
source3/smbd/mangle_hash.c | 6 ++--
source3/smbd/mangle_hash2.c | 12 ++++----
source3/web/swat.c | 2 +-
13 files changed, 60 insertions(+), 64 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/auth/pass_check.c b/source3/auth/pass_check.c
index a7a1c3d..77ee31a 100644
--- a/source3/auth/pass_check.c
+++ b/source3/auth/pass_check.c
@@ -518,9 +518,9 @@ static NTSTATUS string_combinations2(char *s, int offset,
for (i = offset; i < (len - (N - 1)); i++) {
char c = s[i];
- if (!islower_ascii(c))
+ if (!islower_m(c))
continue;
- s[i] = toupper_ascii(c);
+ s[i] = toupper_m(c);
nt_status = string_combinations2(s, i + 1, fn, N - 1,
private_data);
if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_WRONG_PASSWORD)) {
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index f8178c7..542ecca 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -490,7 +490,7 @@ static int strslashcmp(char *s1, char *s2)
{
char *s1_0=s1;
- while(*s1 && *s2 && (*s1 == *s2 || tolower_ascii(*s1) == tolower_ascii(*s2) ||
+ while(*s1 && *s2 && (*s1 == *s2 || tolower_m(*s1) == tolower_m(*s2) ||
(*s1 == '\\' && *s2=='/') || (*s1 == '/' && *s2=='\\'))) {
s1++; s2++;
}
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 6291f11..393dd77 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1051,10 +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);
-int toupper_ascii(int c);
-int tolower_ascii(int c);
-int isupper_ascii(int c);
-int islower_ascii(int c);
+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 fd6cefe..d3f65ca 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 31c6695..bff7382 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/username.c b/source3/lib/username.c
index d5da532..925b44b 100644
--- a/source3/lib/username.c
+++ b/source3/lib/username.c
@@ -196,9 +196,9 @@ static struct passwd *uname_string_combinations2(char *s, TALLOC_CTX *mem_ctx,
for (i=offset;i<(len-(N-1));i++) {
char c = s[i];
- if (!islower_ascii((int)c))
+ if (!islower_m((int)c))
continue;
- s[i] = toupper_ascii(c);
+ s[i] = toupper_m(c);
ret = uname_string_combinations2(s, mem_ctx, i+1, fn, N-1);
if(ret)
return(ret);
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index cabdf9e..4701528 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -243,7 +243,7 @@ int strwicmp(const char *psz1, const char *psz2)
psz1++;
while (isspace((int)*psz2))
psz2++;
- if (toupper_ascii(*psz1) != toupper_ascii(*psz2) ||
+ if (toupper_m(*psz1) != toupper_m(*psz2) ||
*psz1 == '\0' || *psz2 == '\0')
break;
psz1++;
@@ -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;
}
}
@@ -1406,7 +1406,7 @@ void strlower_m(char *s)
(ie. they match for the first 128 chars) */
while (*s && !(((unsigned char)s[0]) & 0x80)) {
- *s = tolower_ascii((unsigned char)*s);
+ *s = tolower_m((unsigned char)*s);
s++;
}
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c
index 5204e9b..b8bece1 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;
}
/*******************************************************************
@@ -607,40 +607,36 @@ smb_ucs2_t *strstr_wa(const smb_ucs2_t *s, const char *ins)
return NULL;
}
-/*************************************************************
- ascii only toupper - saves the need for smbd to be in C locale.
-*************************************************************/
-
-int toupper_ascii(int c)
+smb_ucs2_t toupper_w(smb_ucs2_t v)
{
- smb_ucs2_t uc = toupper_m(UCS2_CHAR(c));
- return UCS2_TO_CHAR(uc);
+ 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;
}
-/*************************************************************
- ascii only tolower - saves the need for smbd to be in C locale.
-*************************************************************/
-
-int tolower_ascii(int c)
+bool isupper_w(smb_ucs2_t v)
{
- smb_ucs2_t uc = tolower_m(UCS2_CHAR(c));
- return UCS2_TO_CHAR(uc);
+ codepoint_t cp = SVAL(&v,0);
+ return isupper_m(cp);
}
-/*************************************************************
- ascii only isupper - saves the need for smbd to be in C locale.
-*************************************************************/
-
-int isupper_ascii(int c)
+smb_ucs2_t tolower_w(smb_ucs2_t v)
{
- return isupper_m(UCS2_CHAR(c));
+ 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;
}
-/*************************************************************
- ascii only islower - saves the need for smbd to be in C locale.
-*************************************************************/
-
-int islower_ascii(int c)
+bool islower_w(smb_ucs2_t v)
{
- return islower_m(UCS2_CHAR(c));
+ codepoint_t cp = SVAL(&v,0);
+ return islower_m(cp);
}
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 1ec68ad..0a1a4b0 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -7540,9 +7540,9 @@ static bool handle_dos_charset(int snum, const char *pszParmValue, char **ptr)
if (len == 4 || len == 5) {
/* Don't use StrCaseCmp here as we don't want to
initialize iconv. */
- if ((toupper_ascii(pszParmValue[0]) == 'U') &&
- (toupper_ascii(pszParmValue[1]) == 'T') &&
- (toupper_ascii(pszParmValue[2]) == 'F')) {
+ if ((toupper_m(pszParmValue[0]) == 'U') &&
+ (toupper_m(pszParmValue[1]) == 'T') &&
+ (toupper_m(pszParmValue[2]) == 'F')) {
if (len == 4) {
if (pszParmValue[3] == '8') {
is_utf8 = true;
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index c49fb24..52c1129 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -407,8 +407,8 @@ bool pdb_gethexpwd(const char *p, unsigned char *pwd)
return false;
for (i = 0; i < 32; i += 2) {
- hinybble = toupper_ascii(p[i]);
- lonybble = toupper_ascii(p[i + 1]);
+ hinybble = toupper_m(p[i]);
+ lonybble = toupper_m(p[i + 1]);
p1 = strchr(hexchars, hinybble);
p2 = strchr(hexchars, lonybble);
@@ -457,8 +457,8 @@ bool pdb_gethexhours(const char *p, unsigned char *hours)
}
for (i = 0; i < 42; i += 2) {
- hinybble = toupper_ascii(p[i]);
- lonybble = toupper_ascii(p[i + 1]);
+ hinybble = toupper_m(p[i]);
+ lonybble = toupper_m(p[i + 1]);
p1 = strchr(hexchars, hinybble);
p2 = strchr(hexchars, lonybble);
diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c
index adeb542..bafcd03 100644
--- a/source3/smbd/mangle_hash.c
+++ b/source3/smbd/mangle_hash.c
@@ -374,8 +374,8 @@ static bool is_mangled(const char *s, const struct share_params *p)
magic = strchr_m( s, magic_char );
while( magic && magic[1] && magic[2] ) { /* 3 chars, 1st is magic. */
if( ('.' == magic[3] || '/' == magic[3] || !(magic[3])) /* Ends with '.' or nul or '/' ? */
- && isbasechar( toupper_ascii(magic[1]) ) /* is 2nd char basechar? */
- && isbasechar( toupper_ascii(magic[2]) ) ) /* is 3rd char basechar? */
+ && isbasechar( toupper_m(magic[1]) ) /* is 2nd char basechar? */
+ && isbasechar( toupper_m(magic[2]) ) ) /* is 3rd char basechar? */
return( True ); /* If all above, then true, */
magic = strchr_m( magic+1, magic_char ); /* else seek next magic. */
}
@@ -429,7 +429,7 @@ static void cache_mangled_name( const char mangled_name[13],
s1 = strrchr( mangled_name_key, '.' );
if( s1 && (s2 = strrchr( raw_name, '.' )) ) {
size_t i = 1;
- while( s1[i] && (tolower_ascii( s1[i] ) == s2[i]) )
+ while( s1[i] && (tolower_m( s1[i] ) == s2[i]) )
i++;
if( !s1[i] && !s2[i] ) {
/* Truncate at the '.' */
diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c
index 4d10089..5aafe2f 100644
--- a/source3/smbd/mangle_hash2.c
+++ b/source3/smbd/mangle_hash2.c
@@ -173,10 +173,10 @@ static void init_tables(void)
char_flags[c2] |= FLAG_POSSIBLE2;
char_flags[c3] |= FLAG_POSSIBLE3;
char_flags[c4] |= FLAG_POSSIBLE4;
- char_flags[tolower_ascii(c1)] |= FLAG_POSSIBLE1;
- char_flags[tolower_ascii(c2)] |= FLAG_POSSIBLE2;
- char_flags[tolower_ascii(c3)] |= FLAG_POSSIBLE3;
- char_flags[tolower_ascii(c4)] |= FLAG_POSSIBLE4;
+ char_flags[tolower_m(c1)] |= FLAG_POSSIBLE1;
+ char_flags[tolower_m(c2)] |= FLAG_POSSIBLE2;
+ char_flags[tolower_m(c3)] |= FLAG_POSSIBLE3;
+ char_flags[tolower_m(c4)] |= FLAG_POSSIBLE4;
char_flags[(unsigned char)'.'] |= FLAG_POSSIBLE4;
}
@@ -734,7 +734,7 @@ static bool hash2_name_to_8_3(const char *name,
if (! FLAG_CHECK(lead_chars[i], FLAG_ASCII)) {
lead_chars[i] = '_';
}
- lead_chars[i] = toupper_ascii(lead_chars[i]);
+ lead_chars[i] = toupper_m(lead_chars[i]);
}
for (;i<mangle_prefix;i++) {
lead_chars[i] = '_';
@@ -755,7 +755,7 @@ static bool hash2_name_to_8_3(const char *name,
char c = dot_p[i];
if (FLAG_CHECK(c, FLAG_ASCII)) {
extension[extension_length++] =
- toupper_ascii(c);
+ toupper_m(c);
}
}
}
diff --git a/source3/web/swat.c b/source3/web/swat.c
index d00ead5..38f6475 100644
--- a/source3/web/swat.c
+++ b/source3/web/swat.c
@@ -123,7 +123,7 @@ static char *stripspaceupper(const char *str)
char *p = newstring;
while (*str) {
- if (*str != ' ') *p++ = toupper_ascii(*str);
+ if (*str != ' ') *p++ = toupper_m(*str);
++str;
}
*p = '\0';
--
Samba Shared Repository
More information about the samba-cvs
mailing list