1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Fix for bug #30453: String not cast to int correctly.

Problem:

my_strntoull10rnd_8bit() handled incorrectly cases when the input
string contains a decimal point and is long enough to overrun the
'unsigned long long' type. The position of the decimal point was not
taken into account which resulted in miscalculated numbers and
truncation to appropriate SQL data type limits.

Solution:

Fix my_strntoull10rnd_8bit() to take the position of a decimal point
into account in such cases.
This commit is contained in:
kaa@polly.(none)
2007-10-15 10:34:34 +04:00
parent 7ed0b70cce
commit e0691da0c1
3 changed files with 38 additions and 5 deletions

View File

@ -1538,14 +1538,18 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)),
}
else
addon= (*str >= '5');
for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++)
if (!dot)
{
if (!dot)
shift++;
for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; shift++, str++);
if (str < end && *str == '.')
{
str++;
for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++);
}
}
if (str < end && *str == '.' && !dot)
else
{
str++;
shift= dot - str;
for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++);
}
goto exp;