diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 5a5c363bbfbe..3e64004b8377 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1517,7 +1517,7 @@ my_strntoull10rnd_8bit(const CHARSET_INFO *cs MY_ATTRIBUTE((unused)), str++; if (str < end) { - int negative_exp, exponent; + longlong negative_exp, exponent; if ((negative_exp= (*str == '-')) || *str=='+') { if (++str == end) @@ -1527,7 +1527,10 @@ my_strntoull10rnd_8bit(const CHARSET_INFO *cs MY_ATTRIBUTE((unused)), str < end && (ch= (uchar) (*str - '0')) < 10; str++) { - exponent= exponent * 10 + ch; + if (exponent <= (LLONG_MAX - ch) / 10) + exponent= exponent * 10 + ch; + else + goto ret_too_big; } shift+= negative_exp ? -exponent : exponent; }