[PATCH 11/13] sql: fixes an error in string to int64 conversion

Stanislav Zudin szudin at tarantool.org
Fri Mar 15 18:45:40 MSK 2019


Returns an error if length of the recognized 
string is less than length of the token.
---
 src/box/sql/util.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/box/sql/util.c b/src/box/sql/util.c
index 980932f3b..17268aaaa 100644
--- a/src/box/sql/util.c
+++ b/src/box/sql/util.c
@@ -599,6 +599,7 @@ sqlAtoF(const char *z, double *pResult, int length)
 enum atoi_result
 sql_atoi64(const char *z, int64_t *val, int length)
 {
+	const char* expected_end = z + length;
 	int neg = 0;		/* assume positive */
 	const char *zEnd = z + length;
 	int incr = 1;
@@ -614,7 +615,7 @@ sql_atoi64(const char *z, int64_t *val, int length)
 
 	char* end = NULL;
 	u64 u = strtoull(z, &end, 10);
-	if (end == z)
+	if (end < expected_end)
 		return ATOI_OVERFLOW;
 	if (errno == ERANGE)
 		return ATOI_OVERFLOW;
-- 
2.17.1




More information about the Tarantool-patches mailing list