lib/util: move memcache.[ch] to the toplevel 'samba-util' library
[nivanova/samba-autobuild/.git] / source3 / smbd / mangle_hash2.c
index 09cd44d5af313f09aeacc9106fb7eb066a559c6d..ac1f4b0f4fb40748e77dc8e774b57bd157a03e3e 100644 (file)
@@ -66,7 +66,7 @@
 #include "includes.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
-#include "memcache.h"
+#include "../lib/util/memcache.h"
 #include "mangle.h"
 
 #if 1
@@ -291,7 +291,7 @@ static unsigned int mangle_hash(const char *key, unsigned int length)
        length = MIN(length,sizeof(fstring)-1);
        strncpy(str, key, length);
        str[length] = 0;
-       strupper_m(str);
+       (void)strupper_m(str);
 
        /* the length of a multi-byte string can change after a strupper_m */
        length = strlen(str);
@@ -626,21 +626,17 @@ 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
-                        * contain embedded ascii bytes. We are really checking
-                        * for mb UNIX asian characters like Japanese (SJIS) here.
-                        * JRA.
+                        * Note that we're only looking for multibyte
+                        * encoding here. No encoding with a length > 1
+                        * contains invalid characters.
                         */
-                       if (convert_string(CH_UNIX, CH_UTF16LE, name, 2, mbc, 2, &size)) {
-                               if (size == 2) {
-                                       /* Was a good mb string. */
-                                       name += 2;
-                                       continue;
-                               }
+                       if (size > 1) {
+                               /* Was a mb string. */
+                               name += size;
+                               continue;
                        }
                }