summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorunknown <kaa@polly.(none)>2007-10-15 10:34:34 +0400
committerunknown <kaa@polly.(none)>2007-10-15 10:34:34 +0400
commit37bac1b09147e6627f767cd0ead8a1fd982f3e76 (patch)
tree5d67a26046a389ccea7dc8033cc84ade4151240b /strings
parent89edb16c4addab848e9956818c078f6c8aec576d (diff)
downloadmariadb-git-37bac1b09147e6627f767cd0ead8a1fd982f3e76.tar.gz
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. mysql-test/r/insert.result: Added a test case for bug #30453. mysql-test/t/insert.test: Added a test case for bug #30453. strings/ctype-simple.c: In cases when the 'unsigned long long' type is overrun by the input string and a decimal point has occurred, adjust the 'shift' according to the position of the decimal point and skip all subsequent digits.
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-simple.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index 8b1b0d6790d..e073262cd4c 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -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;