From 705dde6323d9d590f470dd381ac8ee263460a889 Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Tue, 5 May 2020 16:34:28 +0800 Subject: [PATCH] [td-168] fix binary|nchar length validation bug. --- src/client/src/tscParseInsert.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 8f40cf6fb9..2ce3748dd1 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -310,7 +310,7 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload, *payload = TSDB_DATA_BINARY_NULL; } else { // too long values will return invalid sql, not be truncated automatically - if (pToken->n > pSchema->bytes) { + if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) { return tscInvalidSQLErrMsg(msg, "string data overflow", pToken->z); } @@ -328,7 +328,7 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload, } else { // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' int32_t resLen = -1; - if (!taosMbsToUcs4(pToken->z, pToken->n, payload + VARSTR_HEADER_SIZE, pSchema->bytes, &resLen)) { + if (!taosMbsToUcs4(pToken->z, pToken->n, payload + VARSTR_HEADER_SIZE, pSchema->bytes - VARSTR_HEADER_SIZE, &resLen)) { char buf[512] = {0}; snprintf(buf, 512, "%s", strerror(errno)); -- GitLab