Fix is_legal_name() to not emit character conversion error messages.
[samba.git] / source3 / smbd / mangle_hash2.c
index 7c85a413cb9830a5d151806a0061c46c94ce4f7b..90d9498e5392de8428095125fdecbf36f6b91650 100644 (file)
 
 
 #include "includes.h"
+#include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "memcache.h"
+#include "mangle.h"
 
 #if 1
 #define M_DEBUG(level, x) DEBUG(level, x)
@@ -171,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;
        }
@@ -624,7 +626,8 @@ static bool is_legal_name(const char *name)
        while (*name) {
                if (((unsigned int)name[0]) > 128 && (name[1] != 0)) {
                        /* Possible start of mb character. */
-                       char mbc[2];
+                       size_t size = 0;
+                       (void)next_codepoint(name, &size);
                        /*
                         * Note that if CH_UNIX is utf8 a string may be 3
                         * bytes, but this is ok as mb utf8 characters don't
@@ -632,9 +635,9 @@ static bool is_legal_name(const char *name)
                         * for mb UNIX asian characters like Japanese (SJIS) here.
                         * JRA.
                         */
-                       if (convert_string(CH_UNIX, CH_UTF16LE, name, 2, mbc, 2, False) == 2) {
-                               /* Was a good mb string. */
-                               name += 2;
+                       if (size > 1) {
+                               /* Was a mb string. */
+                               name += size;
                                continue;
                        }
                }
@@ -732,7 +735,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] = '_';
@@ -753,7 +756,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);
                        }
                }
        }