Fix is_legal_name() to not emit character conversion error messages.
authorJeremy Allison <jra@samba.org>
Tue, 10 Sep 2013 17:46:18 +0000 (10:46 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 11 Sep 2013 23:38:43 +0000 (16:38 -0700)
Using next_codepoint() does the same check, but without the conversion
message.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/smbd/mangle_hash2.c

index 655c72745a47c13e8f15817cd88daf790f790b8d..c2910f82c85ecb8ae1fb81e51a577f8a3c309ffd 100644 (file)
@@ -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;
                        }
                }