Fix convert_string() to take a *converted_size arg. and return a bool.
[ira/wip.git] / source3 / smbd / mangle_hash2.c
index 367c21688ac2013b72a312566e9af8009ec513f2..a39bb895c28ba03c0f5e90f7193746549e465f0c 100644 (file)
@@ -627,6 +627,7 @@ static bool is_legal_name(const char *name)
                if (((unsigned int)name[0]) > 128 && (name[1] != 0)) {
                        /* Possible start of mb character. */
                        char mbc[2];
+                       size_t size = 0;
                        /*
                         * Note that if CH_UNIX is utf8 a string may be 3
                         * bytes, but this is ok as mb utf8 characters don't
@@ -634,10 +635,12 @@ 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) == 2) {
-                               /* Was a good mb string. */
-                               name += 2;
-                               continue;
+                       if (convert_string(CH_UNIX, CH_UTF16LE, name, 2, mbc, 2, &size)) {
+                               if (size == 2) {
+                                       /* Was a good mb string. */
+                                       name += 2;
+                                       continue;
+                               }
                        }
                }