From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Stanislav Zudin Subject: [PATCH 11/13] sql: fixes an error in string to int64 conversion Date: Fri, 15 Mar 2019 18:45:40 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: To: tarantool-patches@freelists.org, vdavydov.dev@gmail.com Cc: Stanislav Zudin List-ID: 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