Fix is_legal_name() to not emit character conversion error messages.
authorJeremy Allison <jra@samba.org>
Thu, 12 Sep 2013 21:44:58 +0000 (14:44 -0700)
committerKarolin Seeger <kseeger@samba.org>
Wed, 2 Oct 2013 07:21:28 +0000 (09:21 +0200)
Using next_codepoint() does the same check, but without the conversion
message.

Signed-off-by: Jeremy Allison <jra@samba.org>
Fix bug #10139 - valid utf8 filenames cause "invalid conversion error" messages.

source3/smbd/mangle_hash2.c

index 5aafe2f2abb3af5bc5c62af1a15d95565385ea85..90d9498e5392de8428095125fdecbf36f6b91650 100644 (file)
@@ -626,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
@@ -634,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;
                        }
                }