From 9cd28c8c3c6c67f9e8e1d4f21033e9ad19561f7f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 6 Apr 2013 21:29:12 +0200 Subject: MDEV-4244 [PATCH] Buffer overruns and use-after-free errors fixes for gcc 4.8 - compilation warnings and -fsanitize=address --- strings/ctype-utf8.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'strings') diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 425f5884392..9404afc5f11 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -4261,6 +4261,10 @@ static char filename_safe_char[128]= #define MY_FILENAME_ESCAPE '@' +/* + note, that we cannot trust 'e' here, it's may be fake, + see strconvert() +*/ static int my_mb_wc_filename(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *pwc, const uchar *s, const uchar *e) @@ -4282,7 +4286,7 @@ my_mb_wc_filename(CHARSET_INFO *cs __attribute__((unused)), return MY_CS_TOOSMALL3; byte1= s[1]; - byte2= s[2]; + byte2= byte1 ? s[2] : 0; if (byte1 >= 0x30 && byte1 <= 0x7F && byte2 >= 0x30 && byte2 <= 0x7F) @@ -4307,7 +4311,7 @@ my_mb_wc_filename(CHARSET_INFO *cs __attribute__((unused)), (byte2= hexlo(byte2)) >= 0) { int byte3= hexlo(s[3]); - int byte4= hexlo(s[4]); + int byte4= hexlo(s[3] ? s[4] : 0); if (byte3 >=0 && byte4 >=0) { *pwc= (byte1 << 12) + (byte2 << 8) + (byte3 << 4) + byte4; -- cgit v1.2.1