Check for embedded mb chars when testing for illegal characters like /.
authorJeremy Allison <jra@samba.org>
Wed, 27 Aug 2003 19:01:55 +0000 (19:01 +0000)
committerJeremy Allison <jra@samba.org>
Wed, 27 Aug 2003 19:01:55 +0000 (19:01 +0000)
Should fix mangling for Japanese language.
Jeremy.
(This used to be commit a238bcc440e310a9ea7800e4fb0b4d39c1f0a0d7)

source3/smbd/mangle_hash2.c

index ee0ef69feb3d771db089bd1fce1c01b905ce2daf..9cd0438d5134425bc7db64cc0656a0ec5f264c3c 100644 (file)
@@ -304,7 +304,8 @@ static BOOL is_8_3(const char *name, BOOL check_case, BOOL allow_wildcards)
         the result we need in this case. Using strlen_m would not
         only be slower, it would be incorrect */
        len = strlen(name);
-       if (len > 12) return False;
+       if (len > 12)
+               return False;
 
        /* find the '.'. Note that once again we use the non-multibyte
            function */
@@ -448,6 +449,27 @@ static BOOL is_legal_name(const char *name)
        size_t numdots = 0;
 
        while (*name) {
+               if (((unsigned int)name[0]) > 128 && (name[1] != 0)) {
+                       /* Possible start of mb character. */
+                       char mbc[2];
+                       /*
+                        * We know the following will return 2 bytes. What
+                        * we need to know was if errno was set.
+                        * 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.
+                        */
+                       errno = 0;
+                       convert_string(CH_UNIX, CH_UCS2, name, 2, mbc, 2);
+                       if (!errno) {
+                               /* Was a good mb string. */
+                               name += 2;
+                               continue;
+                       }
+               }
+
                if (FLAG_CHECK(name[0], FLAG_ILLEGAL)) {
                        return False;
                }