summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-10-09 05:20:05 +0400
committerAlexander Barkov <bar@mariadb.com>2018-10-09 07:50:24 +0400
commitc57bbb259684069e87cbae12c7c04a4284af15c3 (patch)
tree91f50f373ad602aef5525b790750e4374377f845 /sql-common
parentf3761539b32e2f82d93dc3c74d7b16a3d5f93063 (diff)
downloadmariadb-git-c57bbb259684069e87cbae12c7c04a4284af15c3.tar.gz
MDEV-17400 The result of TIME('42949672965959-01') depends on architecture
- Fixing portabibily problems in sql-common/my_time.c (and additionally in sql/sql_time.cc) - Re-enabling func_time.test Now all new chunks added in MDEV-17351 work fine on all platforms.
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/my_time.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 008b339e955..c2e5aeee44b 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -610,7 +610,11 @@ str_to_DDhhmmssff_internal(my_bool neg, const char *str, size_t length,
l_time->neg= neg;
/* Not a timestamp. Try to get this as a DAYS TO SECOND string */
for (value=0; str != end && my_isdigit(&my_charset_latin1,*str) ; str++)
+ {
value=value*10L + (long) (*str - '0');
+ if (value >= 42949672955959ULL) /* i.e. UINT_MAX32 : 59 : 59 */
+ goto err;
+ }
/* Skip all space after 'days' */
end_of_days= str;
@@ -629,6 +633,8 @@ str_to_DDhhmmssff_internal(my_bool neg, const char *str, size_t length,
my_isdigit(&my_charset_latin1, str[1]))
{
date[0]= 0; /* Assume we found hours */
+ if (value >= UINT_MAX32)
+ goto err;
date[1]= (ulong) value;
state=2;
found_hours=1;
@@ -638,6 +644,7 @@ str_to_DDhhmmssff_internal(my_bool neg, const char *str, size_t length,
{
/* String given as one number; assume HHMMSS format */
date[0]= 0;
+ DBUG_ASSERT(value <= ((ulonglong) UINT_MAX32) * 10000ULL);
date[1]= (ulong) (value/10000);
date[2]= (ulong) (value/100 % 100);
date[3]= (ulong) (value % 100);