Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
88f0d2c8
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
88f0d2c8
编写于
6月 09, 2020
作者:
B
Bomin Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-459: fix some strncpy
上级
1e7fd87d
变更
15
显示空白变更内容
内联
并排
Showing
15 changed file
with
29 addition
and
33 deletion
+29
-33
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+4
-4
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+2
-4
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+3
-3
src/client/src/tscServer.c
src/client/src/tscServer.c
+4
-4
src/client/src/tscSql.c
src/client/src/tscSql.c
+1
-1
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+5
-5
src/os/darwin/src/darwinPlatform.c
src/os/darwin/src/darwinPlatform.c
+1
-1
src/os/linux/src/linuxSysPara.c
src/os/linux/src/linuxSysPara.c
+2
-2
src/os/windows/src/twindows.c
src/os/windows/src/twindows.c
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+0
-1
src/query/src/qtsbuf.c
src/query/src/qtsbuf.c
+1
-1
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+1
-1
src/util/src/tsched.c
src/util/src/tsched.c
+2
-2
src/util/src/ttimer.c
src/util/src/ttimer.c
+1
-2
tests/tsim/src/simParse.c
tests/tsim/src/simParse.c
+1
-1
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
88f0d2c8
...
...
@@ -795,7 +795,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
STableMetaInfo
*
pSTableMeterMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
STABLE_INDEX
);
tscSetTableFullName
(
pSTableMeterMetaInfo
,
&
sToken
,
pSql
);
strncpy
(
pTag
->
name
,
pSTableMeterMetaInfo
->
name
,
TSDB_TABLE_ID_LEN
);
tstrncpy
(
pTag
->
name
,
pSTableMeterMetaInfo
->
name
,
sizeof
(
pTag
->
name
)
);
code
=
tscGetTableMeta
(
pSql
,
pSTableMeterMetaInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -989,7 +989,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
int
validateTableName
(
char
*
tblName
,
int
len
)
{
char
buf
[
TSDB_TABLE_ID_LEN
]
=
{
0
};
strncpy
(
buf
,
tblName
,
len
);
tstrncpy
(
buf
,
tblName
,
sizeof
(
buf
)
);
SSQLToken
token
=
{.
n
=
len
,
.
type
=
TK_ID
,
.
z
=
buf
};
tSQLGetToken
(
buf
,
&
token
.
type
);
...
...
@@ -1512,7 +1512,7 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
}
pCmd
->
count
=
1
;
strncpy
(
path
,
pDataBlock
->
filename
,
PATH_MAX
);
tstrncpy
(
path
,
pDataBlock
->
filename
,
sizeof
(
path
)
);
FILE
*
fp
=
fopen
(
path
,
"r"
);
if
(
fp
==
NULL
)
{
...
...
@@ -1520,7 +1520,7 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
continue
;
}
strncpy
(
pTableMetaInfo
->
name
,
pDataBlock
->
tableId
,
TSDB_TABLE_ID_LEN
);
tstrncpy
(
pTableMetaInfo
->
name
,
pDataBlock
->
tableId
,
sizeof
(
pTableMetaInfo
->
name
)
);
memset
(
pDataBlock
->
pData
,
0
,
pDataBlock
->
nAllocSize
);
int32_t
ret
=
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
...
...
src/client/src/tscProfile.c
浏览文件 @
88f0d2c8
...
...
@@ -239,8 +239,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
continue
;
}
strncpy
(
pQdesc
->
sql
,
pSql
->
sqlstr
,
TSDB_SHOW_SQL_LEN
-
1
);
pQdesc
->
sql
[
TSDB_SHOW_SQL_LEN
-
1
]
=
0
;
tstrncpy
(
pQdesc
->
sql
,
pSql
->
sqlstr
,
sizeof
(
pQdesc
->
sql
));
pQdesc
->
stime
=
htobe64
(
pSql
->
stime
);
pQdesc
->
queryId
=
htonl
(
pSql
->
queryId
);
pQdesc
->
useconds
=
htobe64
(
pSql
->
res
.
useconds
);
...
...
@@ -256,8 +255,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
SSqlStream
*
pStream
=
pObj
->
streamList
;
while
(
pStream
)
{
strncpy
(
pSdesc
->
sql
,
pStream
->
pSql
->
sqlstr
,
TSDB_SHOW_SQL_LEN
-
1
);
pSdesc
->
sql
[
TSDB_SHOW_SQL_LEN
-
1
]
=
0
;
tstrncpy
(
pSdesc
->
sql
,
pStream
->
pSql
->
sqlstr
,
sizeof
(
pSdesc
->
sql
));
pSdesc
->
streamId
=
htonl
(
pStream
->
streamId
);
pSdesc
->
num
=
htobe64
(
pStream
->
num
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
88f0d2c8
...
...
@@ -1309,7 +1309,7 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
pIndex
->
columnIndex
);
char
*
colName
=
(
pItem
->
aliasName
==
NULL
)
?
pSchema
->
name
:
pItem
->
aliasName
;
strncpy
(
pExpr
->
aliasName
,
colName
,
tListLen
(
pExpr
->
aliasName
));
tstrncpy
(
pExpr
->
aliasName
,
colName
,
sizeof
(
pExpr
->
aliasName
));
SColumnList
ids
=
{
0
};
ids
.
num
=
1
;
...
...
@@ -1359,7 +1359,7 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum
for
(
int32_t
j
=
0
;
j
<
numOfTotalColumns
;
++
j
)
{
SSqlExpr
*
pExpr
=
doAddProjectCol
(
pQueryInfo
,
startPos
+
j
,
j
,
pIndex
->
tableIndex
);
strncpy
(
pExpr
->
aliasName
,
pSchema
[
j
].
name
,
tListLen
(
pExpr
->
aliasName
));
tstrncpy
(
pExpr
->
aliasName
,
pSchema
[
j
].
name
,
sizeof
(
pExpr
->
aliasName
));
pIndex
->
columnIndex
=
j
;
SColumnList
ids
=
{
0
};
...
...
@@ -1453,7 +1453,7 @@ static int32_t setExprInfoForFunctions(SQueryInfo* pQueryInfo, SSchema* pSchema,
}
SSqlExpr
*
pExpr
=
tscSqlExprAppend
(
pQueryInfo
,
functionID
,
pColIndex
,
type
,
bytes
,
bytes
,
false
);
strncpy
(
pExpr
->
aliasName
,
columnName
,
tListLen
(
pExpr
->
aliasName
));
tstrncpy
(
pExpr
->
aliasName
,
columnName
,
sizeof
(
pExpr
->
aliasName
));
// for all queries, the timestamp column needs to be loaded
SColumnIndex
index
=
{.
tableIndex
=
pColIndex
->
tableIndex
,
.
columnIndex
=
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
...
...
src/client/src/tscServer.c
浏览文件 @
88f0d2c8
...
...
@@ -866,7 +866,7 @@ int32_t tscBuildCreateDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
assert
(
pCmd
->
numOfClause
==
1
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strncpy
(
pCreateDbMsg
->
db
,
pTableMetaInfo
->
name
,
tListLen
(
pCreateDbMsg
->
db
));
tstrncpy
(
pCreateDbMsg
->
db
,
pTableMetaInfo
->
name
,
sizeof
(
pCreateDbMsg
->
db
));
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2153,8 +2153,8 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
strcpy
(
pObj
->
acctId
,
pConnect
->
acctId
);
// copy acctId from response
int32_t
len
=
sprintf
(
temp
,
"%s%s%s"
,
pObj
->
acctId
,
TS_PATH_DELIMITER
,
pObj
->
db
);
assert
(
len
<=
tListLen
(
pObj
->
db
));
strncpy
(
pObj
->
db
,
temp
,
tListLen
(
pObj
->
db
));
assert
(
len
<=
sizeof
(
pObj
->
db
));
tstrncpy
(
pObj
->
db
,
temp
,
sizeof
(
pObj
->
db
));
if
(
pConnect
->
ipList
.
numOfIps
>
0
)
tscSetMgmtIpList
(
&
pConnect
->
ipList
);
...
...
@@ -2338,7 +2338,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
STableMetaInfo
*
pNewMeterMetaInfo
=
tscAddEmptyMetaInfo
(
pNewQueryInfo
);
assert
(
pNew
->
cmd
.
numOfClause
==
1
&&
pNewQueryInfo
->
numOfTables
==
1
);
strncpy
(
pNewMeterMetaInfo
->
name
,
pTableMetaInfo
->
name
,
tListLen
(
pNewMeterMetaInfo
->
name
));
tstrncpy
(
pNewMeterMetaInfo
->
name
,
pTableMetaInfo
->
name
,
sizeof
(
pNewMeterMetaInfo
->
name
));
memcpy
(
pNew
->
cmd
.
payload
,
pSql
->
cmd
.
payload
,
pSql
->
cmd
.
payloadLen
);
// tag information if table does not exists.
pNew
->
cmd
.
payloadLen
=
pSql
->
cmd
.
payloadLen
;
tscTrace
(
"%p new pSqlObj:%p to get tableMeta, auto create:%d"
,
pSql
,
pNew
,
pNew
->
cmd
.
autoCreated
);
...
...
src/client/src/tscSql.c
浏览文件 @
88f0d2c8
...
...
@@ -86,7 +86,7 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
pObj
->
signature
=
pObj
;
strncpy
(
pObj
->
user
,
user
,
TSDB_USER_LEN
);
tstrncpy
(
pObj
->
user
,
user
,
sizeof
(
pObj
->
user
)
);
taosEncryptPass
((
uint8_t
*
)
pass
,
strlen
(
pass
),
pObj
->
pass
);
if
(
db
)
{
...
...
src/client/src/tscSystem.c
浏览文件 @
88f0d2c8
...
...
@@ -180,7 +180,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
assert
(
cfg
!=
NULL
);
if
(
cfg
->
cfgStatus
<=
TAOS_CFG_CSTATUS_OPTION
)
{
strncpy
(
configDir
,
pStr
,
TSDB_FILENAME_LEN
);
t
strncpy
(
configDir
,
pStr
,
TSDB_FILENAME_LEN
);
cfg
->
cfgStatus
=
TAOS_CFG_CSTATUS_OPTION
;
tscPrint
(
"set config file directory:%s"
,
pStr
);
}
else
{
...
...
@@ -234,7 +234,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
tscPrint
(
"failed to set locale:%s, current locale:%s"
,
pStr
,
tsLocale
);
}
strncpy
(
tsLocale
,
locale
,
tListLen
(
tsLocale
));
tstrncpy
(
tsLocale
,
locale
,
sizeof
(
tsLocale
));
char
*
charset
=
strrchr
(
tsLocale
,
sep
);
if
(
charset
!=
NULL
)
{
...
...
@@ -249,7 +249,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
tscPrint
(
"charset changed from %s to %s"
,
tsCharset
,
charset
);
}
strncpy
(
tsCharset
,
charset
,
tListLen
(
tsCharset
));
tstrncpy
(
tsCharset
,
charset
,
sizeof
(
tsCharset
));
cfg
->
cfgStatus
=
TAOS_CFG_CSTATUS_OPTION
;
}
else
{
...
...
@@ -286,7 +286,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
tscPrint
(
"charset changed from %s to %s"
,
tsCharset
,
pStr
);
}
strncpy
(
tsCharset
,
pStr
,
tListLen
(
tsCharset
));
tstrncpy
(
tsCharset
,
pStr
,
sizeof
(
tsCharset
));
cfg
->
cfgStatus
=
TAOS_CFG_CSTATUS_OPTION
;
}
else
{
tscPrint
(
"charset:%s not valid"
,
pStr
);
...
...
@@ -324,7 +324,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
// return -1;
// }
strncpy
(
tsSocketType
,
pStr
,
tListLen
(
tsSocketType
));
tstrncpy
(
tsSocketType
,
pStr
,
sizeof
(
tsSocketType
));
cfg
->
cfgStatus
=
TAOS_CFG_CSTATUS_OPTION
;
tscPrint
(
"socket type is set:%s"
,
tsSocketType
);
}
...
...
src/os/darwin/src/darwinPlatform.c
浏览文件 @
88f0d2c8
...
...
@@ -189,7 +189,7 @@ void taosGetSystemLocale() {
if
(
cfg_locale
&&
cfg_locale
->
cfgStatus
<
TAOS_CFG_CSTATUS_DEFAULT
)
{
char
*
locale
=
setlocale
(
LC_CTYPE
,
"chs"
);
if
(
locale
!=
NULL
)
{
strncpy
(
tsLocale
,
locale
,
sizeof
(
tsLocale
)
/
sizeof
(
tsLocale
[
0
]
));
tstrncpy
(
tsLocale
,
locale
,
sizeof
(
tsLocale
));
cfg_locale
->
cfgStatus
=
TAOS_CFG_CSTATUS_DEFAULT
;
uPrint
(
"locale not configured, set to default:%s"
,
tsLocale
);
}
...
...
src/os/linux/src/linuxSysPara.c
浏览文件 @
88f0d2c8
...
...
@@ -229,7 +229,7 @@ static void taosGetSystemLocale() { // get and set default locale
uError
(
"can't get locale from system, set it to en_US.UTF-8"
);
strcpy
(
tsLocale
,
"en_US.UTF-8"
);
}
else
{
tstrncpy
(
tsLocale
,
locale
,
tListLen
(
tsLocale
));
tstrncpy
(
tsLocale
,
locale
,
sizeof
(
tsLocale
));
uError
(
"locale not configured, set to system default:%s"
,
tsLocale
);
}
}
...
...
@@ -242,7 +242,7 @@ static void taosGetSystemLocale() { // get and set default locale
str
++
;
char
*
revisedCharset
=
taosCharsetReplace
(
str
);
strncpy
(
tsCharset
,
revisedCharset
,
tListLen
(
tsCharset
));
tstrncpy
(
tsCharset
,
revisedCharset
,
sizeof
(
tsCharset
));
free
(
revisedCharset
);
uWarn
(
"charset not configured, set to system default:%s"
,
tsCharset
);
...
...
src/os/windows/src/twindows.c
浏览文件 @
88f0d2c8
...
...
@@ -226,7 +226,7 @@ void taosGetSystemLocale() {
if
(
cfg_locale
&&
cfg_locale
->
cfgStatus
<
TAOS_CFG_CSTATUS_DEFAULT
)
{
char
*
locale
=
setlocale
(
LC_CTYPE
,
"chs"
);
if
(
locale
!=
NULL
)
{
strncpy
(
tsLocale
,
locale
,
sizeof
(
tsLocale
)
/
sizeof
(
tsLocale
[
0
]
));
tstrncpy
(
tsLocale
,
locale
,
sizeof
(
tsLocale
));
cfg_locale
->
cfgStatus
=
TAOS_CFG_CSTATUS_DEFAULT
;
uPrint
(
"locale not configured, set to default:%s"
,
tsLocale
);
}
...
...
src/query/src/qExecutor.c
浏览文件 @
88f0d2c8
...
...
@@ -6038,7 +6038,6 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
for
(
int32_t
j
=
0
;
j
<
pQuery
->
numOfOutput
;
++
j
)
{
if
(
pExprInfo
[
j
].
base
.
colInfo
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
)
{
char
*
data
=
tsdbGetTableName
(
pQInfo
->
tsdb
,
&
item
->
id
);
char
*
dst
=
pQuery
->
sdata
[
j
]
->
data
+
count
*
((
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
);
memcpy
(
dst
,
data
,
varDataTLen
(
data
));
}
else
{
// todo refactor
...
...
src/query/src/qtsbuf.c
浏览文件 @
88f0d2c8
...
...
@@ -51,7 +51,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
return
NULL
;
}
strncpy
(
pTSBuf
->
path
,
path
,
PATH_MAX
);
tstrncpy
(
pTSBuf
->
path
,
path
,
sizeof
(
pTSBuf
->
path
)
);
pTSBuf
->
f
=
fopen
(
pTSBuf
->
path
,
"r+"
);
if
(
pTSBuf
->
f
==
NULL
)
{
...
...
src/rpc/src/rpcMain.c
浏览文件 @
88f0d2c8
...
...
@@ -458,7 +458,7 @@ int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo) {
pInfo
->
clientPort
=
pConn
->
peerPort
;
// pInfo->serverIp = pConn->destIp;
strncpy
(
pInfo
->
user
,
pConn
->
user
,
sizeof
(
pInfo
->
user
));
t
strncpy
(
pInfo
->
user
,
pConn
->
user
,
sizeof
(
pInfo
->
user
));
return
0
;
}
...
...
src/util/src/tsched.c
浏览文件 @
88f0d2c8
...
...
@@ -15,6 +15,7 @@
#include "os.h"
#include "taosdef.h"
#include "tutil.h"
#include "tulog.h"
#include "tsched.h"
#include "ttimer.h"
...
...
@@ -62,8 +63,7 @@ void *taosInitScheduler(int queueSize, int numOfThreads, const char *label) {
}
pSched
->
queueSize
=
queueSize
;
strncpy
(
pSched
->
label
,
label
,
sizeof
(
pSched
->
label
));
// fix buffer overflow
pSched
->
label
[
sizeof
(
pSched
->
label
)
-
1
]
=
'\0'
;
tstrncpy
(
pSched
->
label
,
label
,
sizeof
(
pSched
->
label
));
// fix buffer overflow
pSched
->
fullSlot
=
0
;
pSched
->
emptySlot
=
0
;
...
...
src/util/src/ttimer.c
浏览文件 @
88f0d2c8
...
...
@@ -552,8 +552,7 @@ void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* lab
return
NULL
;
}
strncpy
(
ctrl
->
label
,
label
,
sizeof
(
ctrl
->
label
));
ctrl
->
label
[
sizeof
(
ctrl
->
label
)
-
1
]
=
0
;
tstrncpy
(
ctrl
->
label
,
label
,
sizeof
(
ctrl
->
label
));
tmrTrace
(
"%s timer controller is initialized, number of timer controllers: %d."
,
label
,
numOfTmrCtrl
);
return
ctrl
;
}
...
...
tests/tsim/src/simParse.c
浏览文件 @
88f0d2c8
...
...
@@ -165,7 +165,7 @@ SScript *simBuildScriptObj(char *fileName) {
script
->
type
=
SIM_SCRIPT_TYPE_MAIN
;
script
->
numOfLines
=
numOfLines
;
strncpy
(
script
->
fileName
,
fileName
,
MAX_FILE_NAME_LEN
);
tstrncpy
(
script
->
fileName
,
fileName
,
sizeof
(
script
->
fileName
)
);
script
->
optionBuffer
=
malloc
(
optionOffset
);
memcpy
(
script
->
optionBuffer
,
optionBuffer
,
optionOffset
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录