Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c0e81449
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c0e81449
编写于
8月 12, 2021
作者:
sangshuduo
提交者:
GitHub
8月 12, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6013]<fix>: taosdemo buffer overflow. (#7317)
上级
520050e4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
18 deletion
+31
-18
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+31
-18
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
c0e81449
...
...
@@ -5101,21 +5101,27 @@ static int64_t generateStbRowData(
int64_t
dataLen
=
0
;
char
*
pstr
=
recBuf
;
int64_t
maxLen
=
MAX_DATA_SIZE
;
int
tmpLen
;
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"(%"
PRId64
","
,
timestamp
);
for
(
int
i
=
0
;
i
<
stbInfo
->
columnCount
;
i
++
)
{
if
((
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"BINARY"
,
strlen
(
"BINARY"
)
))
"BINARY"
,
6
))
||
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"NCHAR"
,
strlen
(
"NCHAR"
)
)))
{
"NCHAR"
,
5
)))
{
if
(
stbInfo
->
columns
[
i
].
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
errorPrint
(
"binary or nchar length overflow, max size:%u
\n
"
,
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
return
-
1
;
}
if
((
stbInfo
->
columns
[
i
].
dataLen
+
1
)
>
/* need count 3 extra chars \', \', and , */
(
remainderBufLen
-
dataLen
-
3
))
{
return
0
;
}
char
*
buf
=
(
char
*
)
calloc
(
stbInfo
->
columns
[
i
].
dataLen
+
1
,
1
);
if
(
NULL
==
buf
)
{
errorPrint
(
"calloc failed! size:%d
\n
"
,
stbInfo
->
columns
[
i
].
dataLen
);
...
...
@@ -5129,19 +5135,20 @@ static int64_t generateStbRowData(
char
*
tmp
;
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"INT"
,
strlen
(
"INT"
)
))
{
"INT"
,
3
))
{
if
((
g_args
.
demo_mode
)
&&
(
i
==
1
))
{
tmp
=
demo_voltage_int_str
();
}
else
{
tmp
=
rand_int_str
();
}
tstrncpy
(
pstr
+
dataLen
,
tmp
,
INT_BUFF_LEN
);
tmpLen
=
strlen
(
tmp
);
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
INT_BUFF_LEN
));
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"BIGINT"
,
strlen
(
"BIGINT"
)
))
{
"BIGINT"
,
6
))
{
tmp
=
rand_bigint_str
();
tstrncpy
(
pstr
+
dataLen
,
tmp
,
BIGINT_BUFF_LEN
);
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"FLOAT"
,
strlen
(
"FLOAT"
)
))
{
"FLOAT"
,
5
))
{
if
(
g_args
.
demo_mode
)
{
if
(
i
==
0
)
{
tmp
=
demo_current_float_str
();
...
...
@@ -5151,27 +5158,33 @@ static int64_t generateStbRowData(
}
else
{
tmp
=
rand_float_str
();
}
tstrncpy
(
pstr
+
dataLen
,
tmp
,
FLOAT_BUFF_LEN
);
tmpLen
=
strlen
(
tmp
);
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
FLOAT_BUFF_LEN
));
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"DOUBLE"
,
strlen
(
"DOUBLE"
)
))
{
"DOUBLE"
,
6
))
{
tmp
=
rand_double_str
();
tstrncpy
(
pstr
+
dataLen
,
tmp
,
DOUBLE_BUFF_LEN
);
tmpLen
=
strlen
(
tmp
);
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
DOUBLE_BUFF_LEN
));
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"SMALLINT"
,
strlen
(
"SMALLINT"
)
))
{
"SMALLINT"
,
8
))
{
tmp
=
rand_smallint_str
();
tstrncpy
(
pstr
+
dataLen
,
tmp
,
SMALLINT_BUFF_LEN
);
tmpLen
=
strlen
(
tmp
);
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
SMALLINT_BUFF_LEN
));
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"TINYINT"
,
strlen
(
"TINYINT"
)
))
{
"TINYINT"
,
7
))
{
tmp
=
rand_tinyint_str
();
tstrncpy
(
pstr
+
dataLen
,
tmp
,
TINYINT_BUFF_LEN
);
tmpLen
=
strlen
(
tmp
);
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
TINYINT_BUFF_LEN
));
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"BOOL"
,
strlen
(
"BOOL"
)
))
{
"BOOL"
,
4
))
{
tmp
=
rand_bool_str
();
tstrncpy
(
pstr
+
dataLen
,
tmp
,
BOOL_BUFF_LEN
);
tmpLen
=
strlen
(
tmp
);
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
BOOL_BUFF_LEN
));
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"TIMESTAMP"
,
strlen
(
"TIMESTAMP"
)
))
{
"TIMESTAMP"
,
9
))
{
tmp
=
rand_int_str
();
tstrncpy
(
pstr
+
dataLen
,
tmp
,
INT_BUFF_LEN
);
tmpLen
=
strlen
(
tmp
);
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
INT_BUFF_LEN
));
}
else
{
errorPrint
(
"Not support data type: %s
\n
"
,
stbInfo
->
columns
[
i
].
dataType
);
return
-
1
;
...
...
@@ -5182,7 +5195,7 @@ static int64_t generateStbRowData(
dataLen
+=
1
;
}
if
(
dataLen
>
(
remainderBufLen
-
(
DOUBLE_BUFF_LEN
+
1
)))
if
(
dataLen
>
(
remainderBufLen
-
(
128
)))
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录