From 91d19e458d6e00e2b4c26b228acf1852c2ffd42c Mon Sep 17 00:00:00 2001 From: Shungang Li Date: Thu, 5 Sep 2024 19:43:57 +0800 Subject: [PATCH] enh: error msg for csv file path that is too long --- source/libs/parser/src/parInsertSql.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index a8db514ee3..9412735ded 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -2254,10 +2254,16 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt static int32_t parseDataFromFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, SToken* pFilePath, SRowsDataContext rowsDataCxt) { - char filePathStr[PATH_MAX] = {0}; + char filePathStr[PATH_MAX + 16] = {0}; if (TK_NK_STRING == pFilePath->type) { (void)trimString(pFilePath->z, pFilePath->n, filePathStr, sizeof(filePathStr)); + if (strlen(filePathStr) >= PATH_MAX) { + return buildSyntaxErrMsg(&pCxt->msg, "file path is too long, max length is 4096", pFilePath->z); + } } else { + if (pFilePath->n >= PATH_MAX) { + return buildSyntaxErrMsg(&pCxt->msg, "file path is too long, max length is 4096", pFilePath->z); + } strncpy(filePathStr, pFilePath->z, pFilePath->n); } pStmt->fp = taosOpenFile(filePathStr, TD_FILE_READ | TD_FILE_STREAM);