diff options
author | unknown <bar@mysql.com> | 2005-08-08 19:52:30 +0500 |
---|---|---|
committer | unknown <bar@mysql.com> | 2005-08-08 19:52:30 +0500 |
commit | 4112dc21765162ae3dfd356eedf480720eb32904 (patch) | |
tree | 9af79335dde7a3443f3f55a42ed6fd07728796af /mysys/mf_dirname.c | |
parent | 062258ca7e6d457a978be0be73a6ba727f81b6c8 (diff) | |
download | mariadb-git-4112dc21765162ae3dfd356eedf480720eb32904.tar.gz |
Bug#5439 : mysql_server_init() crashes if ShiftJIS path is passed
(important for Adobe).
mf_pack.c, mf_dirname.c, charset.c, my_sys.h:
- adding fs_character_set() function on Windows
- ignoring fake slashes which are just multibyte
parts in several functions in /mysys
Verified by Shu to work on WinXP and Win2k.
Test is not possible, or very hard to do.
include/my_sys.h:
Bug#5439 : mysql_server_init() crashes if ShiftJIS path is passed
(important for Adobe)
- adding fs_character_set() function on Windows
- ignoring fake slashes which are just multibyte
parts in several functions in /mysys
mysys/charset.c:
d
mysys/mf_dirname.c:
d
mysys/mf_pack.c:
d
Diffstat (limited to 'mysys/mf_dirname.c')
-rw-r--r-- | mysys/mf_dirname.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c index 3de82c05b87..45bf4d56c31 100644 --- a/mysys/mf_dirname.c +++ b/mysys/mf_dirname.c @@ -22,6 +22,9 @@ uint dirname_length(const char *name) { register my_string pos,gpos; +#ifdef BASKSLASH_MBTAIL + CHARSET_INFO *fs= fs_character_set(); +#endif #ifdef FN_DEVCHAR if ((pos=(char*)strrchr(name,FN_DEVCHAR)) == 0) #endif @@ -29,12 +32,22 @@ uint dirname_length(const char *name) gpos= pos++; for ( ; *pos ; pos++) /* Find last FN_LIBCHAR */ + { +#ifdef BASKSLASH_MBTAIL + uint l; + if (use_mb(fs) && (l= my_ismbchar(fs, pos, pos + 3))) + { + pos+= l - 1; + continue; + } +#endif if (*pos == FN_LIBCHAR || *pos == '/' #ifdef FN_C_AFTER_DIR || *pos == FN_C_AFTER_DIR || *pos == FN_C_AFTER_DIR_2 #endif ) gpos=pos; + } return ((uint) (uint) (gpos+1-(char*) name)); } @@ -85,6 +98,9 @@ uint dirname_part(my_string to, const char *name) char *convert_dirname(char *to, const char *from, const char *from_end) { char *to_org=to; +#ifdef BACKSLASH_MBTAIL + CHARSET_INFO *fs= fs_character_set(); +#endif /* We use -2 here, becasue we need place for the last FN_LIBCHAR */ if (!from_end || (from_end - from) > FN_REFLEN-2) @@ -103,7 +119,22 @@ char *convert_dirname(char *to, const char *from, const char *from_end) *to++= FN_C_AFTER_DIR; #endif else - *to++= *from; + { +#ifdef BACKSLASH_MBTAIL + uint l; + if (use_mb(fs) && (l= my_ismbchar(fs, from, from + 3))) + { + memmove(to, from, l); + to+= l; + from+= l - 1; + to_org= to; /* Don't look inside mbchar */ + } + else +#endif + { + *to++= *from; + } + } } *to=0; } |