diff options
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index b8650a5c7e9..3707811f3f6 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -729,7 +729,10 @@ static bool make_date_time(const String *format, const MYSQL_TIME *l_time, For example, '1.1' -> '1.100000' */ -static bool get_interval_info(const char *str, size_t length,CHARSET_INFO *cs, size_t count, ulonglong *values, +#define MAX_DIGITS_IN_TIME_SPEC 20 + +static bool get_interval_info(const char *str, size_t length,CHARSET_INFO *cs, + size_t count, ulonglong *values, bool transform_msec) { const char *end=str+length; @@ -741,11 +744,21 @@ static bool get_interval_info(const char *str, size_t length,CHARSET_INFO *cs, s for (i=0 ; i < count ; i++) { - longlong value; + ulonglong value; const char *start= str; - for (value= 0; str != end && my_isdigit(cs, *str); str++) + const char *local_end= end; + + /* + We limit things to 19 digits to not get an overflow. This is ok as + this function is meant to read up to microseconds + */ + if ((local_end-str) > MAX_DIGITS_IN_TIME_SPEC) + local_end= str+ MAX_DIGITS_IN_TIME_SPEC; + + for (value= 0; str != local_end && my_isdigit(cs, *str) ; str++) value= value*10 + *str - '0'; - if ((field_length= (size_t)(str - start)) >= 20) + + if ((field_length= (size_t)(str - start)) >= MAX_DIGITS_IN_TIME_SPEC) return true; values[i]= value; while (str != end && !my_isdigit(cs,*str)) @@ -2070,9 +2083,9 @@ bool Func_handler_date_add_interval_datetime_arg0_time:: bool Item_date_add_interval::eq(const Item *item, bool binary_cmp) const { - Item_date_add_interval *other= (Item_date_add_interval*) item; if (!Item_func::eq(item, binary_cmp)) return 0; + Item_date_add_interval *other= (Item_date_add_interval*) item; return ((int_type == other->int_type) && (date_sub_interval == other->date_sub_interval)); } |