First part of fix for bug 8310 - toupper_ascii() is broken on big-endian systems
authorJeremy Allison <jra@samba.org>
Tue, 19 Jul 2011 19:21:23 +0000 (12:21 -0700)
committerKarolin Seeger <kseeger@samba.org>
Thu, 21 Jul 2011 18:15:00 +0000 (20:15 +0200)
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.

source3/auth/pass_check.c
source3/client/clitar.c
source3/include/proto.h
source3/lib/username.c
source3/lib/util_str.c
source3/lib/util_unistr.c
source3/param/loadparm.c
source3/passdb/passdb.c
source3/smbd/mangle_hash.c
source3/smbd/mangle_hash2.c
source3/web/swat.c

index a7a1c3d8f5dc617735dc2a074dd7a5714f18d7e9..77ee31ae54c8ab38a904936fff84c39374afbc8d 100644 (file)
@@ -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)) {
index f8178c7db521975a1ff23d7d9ca79af85c1dd641..542ecca22f2c49a17f25e1fb8865d31b3238d0b0 100644 (file)
@@ -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++;
        }
index 6291f111abbc9836750404bf65cb4dcf64ec885f..cf418849d6b0c7a1f9599c0ed6e2a99ed7eec095 100644 (file)
@@ -1051,10 +1051,6 @@ 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);
 
 /* The following definitions come from lib/version.c  */
 
index d5da5321242d14d84cf36383607e09e6b0695d70..925b44bb06c96b28140ba0acb45092d50d2d6617 100644 (file)
@@ -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);
index cabdf9e491c3a1cf1d30107b407381a3ef89778b..733db27b3633e46c89fcefef50364096ce031683 100644 (file)
@@ -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++;
@@ -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++;
        }
 
index 5204e9bb53b0f8d29dae47534f4a4a0bca2b5b9f..d8a360dfcc3df58f1153d1b491c99cb497fe3240 100644 (file)
@@ -606,41 +606,3 @@ 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 uc = toupper_m(UCS2_CHAR(c));
-       return UCS2_TO_CHAR(uc);
-}
-
-/*************************************************************
- ascii only tolower - saves the need for smbd to be in C locale.
-*************************************************************/
-
-int tolower_ascii(int c)
-{
-       smb_ucs2_t uc = tolower_m(UCS2_CHAR(c));
-       return UCS2_TO_CHAR(uc);
-}
-
-/*************************************************************
- ascii only isupper - saves the need for smbd to be in C locale.
-*************************************************************/
-
-int isupper_ascii(int c)
-{
-       return isupper_m(UCS2_CHAR(c));
-}
-
-/*************************************************************
- ascii only islower - saves the need for smbd to be in C locale.
-*************************************************************/
-
-int islower_ascii(int c)
-{
-       return islower_m(UCS2_CHAR(c));
-}
index 1ec68add75cb6e7334ebd958a98ad88238d39ed4..0a1a4b063f79d1c3441370a9a0071e675b0692b7 100644 (file)
@@ -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;
index c49fb2471179a1be06c808b85b74a9db2228e0b8..52c11295120ac97332fa96ab3b1c2d4ad8e99853 100644 (file)
@@ -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);
index adeb542c6ed6e91009ceb60e93a0ea49966984e4..bafcd03d015d8a0b91ece43c3439ead1f34c4ec5 100644 (file)
@@ -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 '.' */
index 4d10089266e5d8b1a91961953b881937ca94d816..5aafe2f2abb3af5bc5c62af1a15d95565385ea85 100644 (file)
@@ -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);
                        }
                }
        }
index d00ead56b4b7a22d42330d6697280d9409437310..38f647570ffb0afafe8983921c3cb0c8c52f5216 100644 (file)
@@ -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';