diff options
author | aivanov@mysql.com <> | 2005-12-15 18:48:08 +0300 |
---|---|---|
committer | aivanov@mysql.com <> | 2005-12-15 18:48:08 +0300 |
commit | ea4c3481f2590510eba5ce915dad47f491f67054 (patch) | |
tree | 9b272029a8f909f6854184ce5fe89b861c838022 /sql-common | |
parent | b21e1d418d1bcc566e6c27cfbad8b1c032aada0c (diff) | |
download | mariadb-git-ea4c3481f2590510eba5ce915dad47f491f67054.tar.gz |
Fixed BUG #12440: "Incorrect processing of time values containing
long fraction and/or large exponent part".
Diffstat (limited to 'sql-common')
-rw-r--r-- | sql-common/my_time.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 40d7799e274..3c46a944ba9 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -514,18 +514,34 @@ fractional: /* Get fractional second part */ if ((end-str) >= 2 && *str == '.' && my_isdigit(&my_charset_latin1,str[1])) { - uint field_length=5; + int field_length= 5; str++; value=(uint) (uchar) (*str - '0'); - while (++str != end && - my_isdigit(&my_charset_latin1,str[0]) && - field_length--) - value=value*10 + (uint) (uchar) (*str - '0'); - if (field_length) + while (++str != end && my_isdigit(&my_charset_latin1, *str)) + { + if (field_length-- > 0) + value= value*10 + (uint) (uchar) (*str - '0'); + } + if (field_length > 0) value*= (long) log_10_int[field_length]; + else if (field_length < 0) + *was_cut= 1; date[4]=value; } else date[4]=0; + + /* Check for exponent part: E<gigit> | E<sign><digit> */ + /* (may occur as result of %g formatting of time value) */ + if ((end - str) > 1 && + (*str == 'e' || *str == 'E') && + (my_isdigit(&my_charset_latin1, str[1]) || + ((str[1] == '-' || str[1] == '+') && + (end - str) > 2 && + my_isdigit(&my_charset_latin1, str[2])))) + { + *was_cut= 1; + return 1; + } if (internal_format_positions[7] != 255) { |