Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
4be7a595
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看板
提交
4be7a595
编写于
6月 02, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix invalid read in taocache
上级
cf840735
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
7 addition
and
8 deletion
+7
-8
src/util/inc/tcache.h
src/util/inc/tcache.h
+1
-1
src/util/src/hash.c
src/util/src/hash.c
+1
-3
src/util/src/tcache.c
src/util/src/tcache.c
+5
-4
未找到文件。
src/util/inc/tcache.h
浏览文件 @
4be7a595
...
@@ -47,7 +47,7 @@ typedef struct SCacheDataNode {
...
@@ -47,7 +47,7 @@ typedef struct SCacheDataNode {
typedef
struct
STrashElem
{
typedef
struct
STrashElem
{
struct
STrashElem
*
prev
;
struct
STrashElem
*
prev
;
struct
STrashElem
*
next
;
struct
STrashElem
*
next
;
SCacheDataNode
*
pData
;
SCacheDataNode
*
pData
;
}
STrashElem
;
}
STrashElem
;
typedef
struct
{
typedef
struct
{
...
...
src/util/src/hash.c
浏览文件 @
4be7a595
...
@@ -529,7 +529,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
...
@@ -529,7 +529,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
}
}
SHashNode
*
doCreateHashNode
(
const
void
*
key
,
size_t
keyLen
,
const
void
*
pData
,
size_t
dsize
,
uint32_t
hashVal
)
{
SHashNode
*
doCreateHashNode
(
const
void
*
key
,
size_t
keyLen
,
const
void
*
pData
,
size_t
dsize
,
uint32_t
hashVal
)
{
size_t
totalSize
=
dsize
+
sizeof
(
SHashNode
)
+
keyLen
+
1
;
// one extra byte for null
size_t
totalSize
=
dsize
+
sizeof
(
SHashNode
)
+
keyLen
;
SHashNode
*
pNewNode
=
calloc
(
1
,
totalSize
);
SHashNode
*
pNewNode
=
calloc
(
1
,
totalSize
);
if
(
pNewNode
==
NULL
)
{
if
(
pNewNode
==
NULL
)
{
...
@@ -544,7 +544,6 @@ SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, s
...
@@ -544,7 +544,6 @@ SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, s
pNewNode
->
keyLen
=
keyLen
;
pNewNode
->
keyLen
=
keyLen
;
pNewNode
->
hashVal
=
hashVal
;
pNewNode
->
hashVal
=
hashVal
;
return
pNewNode
;
return
pNewNode
;
}
}
...
@@ -559,7 +558,6 @@ SHashNode *doUpdateHashNode(SHashNode *pNode, const void *key, size_t keyLen, co
...
@@ -559,7 +558,6 @@ SHashNode *doUpdateHashNode(SHashNode *pNode, const void *key, size_t keyLen, co
memcpy
(
pNewNode
->
data
,
pData
,
dsize
);
memcpy
(
pNewNode
->
data
,
pData
,
dsize
);
pNewNode
->
key
=
pNewNode
->
data
+
dsize
;
pNewNode
->
key
=
pNewNode
->
data
+
dsize
;
assert
(
memcmp
(
pNewNode
->
key
,
key
,
keyLen
)
==
0
&&
keyLen
==
pNewNode
->
keyLen
);
assert
(
memcmp
(
pNewNode
->
key
,
key
,
keyLen
)
==
0
&&
keyLen
==
pNewNode
->
keyLen
);
memcpy
(
pNewNode
->
key
,
key
,
keyLen
);
memcpy
(
pNewNode
->
key
,
key
,
keyLen
);
...
...
src/util/src/tcache.c
浏览文件 @
4be7a595
...
@@ -77,7 +77,7 @@ static FORCE_INLINE void taosFreeNode(void *data) {
...
@@ -77,7 +77,7 @@ static FORCE_INLINE void taosFreeNode(void *data) {
* @param lifespan total survial expiredTime from now
* @param lifespan total survial expiredTime from now
* @return SCacheDataNode
* @return SCacheDataNode
*/
*/
static
SCacheDataNode
*
taosCreate
Hash
Node
(
const
char
*
key
,
size_t
keyLen
,
const
char
*
pData
,
size_t
size
,
static
SCacheDataNode
*
taosCreate
Cache
Node
(
const
char
*
key
,
size_t
keyLen
,
const
char
*
pData
,
size_t
size
,
uint64_t
duration
)
{
uint64_t
duration
)
{
size_t
totalSize
=
size
+
sizeof
(
SCacheDataNode
)
+
keyLen
+
1
;
size_t
totalSize
=
size
+
sizeof
(
SCacheDataNode
)
+
keyLen
+
1
;
...
@@ -242,13 +242,14 @@ static SCacheDataNode *taosUpdateCacheImpl(SCacheObj *pCacheObj, SCacheDataNode
...
@@ -242,13 +242,14 @@ static SCacheDataNode *taosUpdateCacheImpl(SCacheObj *pCacheObj, SCacheDataNode
// only a node is not referenced by any other object, in-place update it
// only a node is not referenced by any other object, in-place update it
if
(
T_REF_VAL_GET
(
pNode
)
==
0
)
{
if
(
T_REF_VAL_GET
(
pNode
)
==
0
)
{
size_t
newSize
=
sizeof
(
SCacheDataNode
)
+
dataSize
+
keyLen
;
size_t
newSize
=
sizeof
(
SCacheDataNode
)
+
dataSize
+
keyLen
+
1
;
pNewNode
=
(
SCacheDataNode
*
)
realloc
(
pNode
,
newSize
);
pNewNode
=
(
SCacheDataNode
*
)
realloc
(
pNode
,
newSize
);
if
(
pNewNode
==
NULL
)
{
if
(
pNewNode
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
memset
(
pNewNode
,
0
,
newSize
);
pNewNode
->
signature
=
(
uint64_t
)
pNewNode
;
pNewNode
->
signature
=
(
uint64_t
)
pNewNode
;
memcpy
(
pNewNode
->
data
,
pData
,
dataSize
);
memcpy
(
pNewNode
->
data
,
pData
,
dataSize
);
...
@@ -267,7 +268,7 @@ static SCacheDataNode *taosUpdateCacheImpl(SCacheObj *pCacheObj, SCacheDataNode
...
@@ -267,7 +268,7 @@ static SCacheDataNode *taosUpdateCacheImpl(SCacheObj *pCacheObj, SCacheDataNode
}
else
{
}
else
{
taosCacheMoveToTrash
(
pCacheObj
,
pNode
);
taosCacheMoveToTrash
(
pCacheObj
,
pNode
);
pNewNode
=
taosCreate
Hash
Node
(
key
,
keyLen
,
pData
,
dataSize
,
duration
);
pNewNode
=
taosCreate
Cache
Node
(
key
,
keyLen
,
pData
,
dataSize
,
duration
);
if
(
pNewNode
==
NULL
)
{
if
(
pNewNode
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -293,7 +294,7 @@ static SCacheDataNode *taosUpdateCacheImpl(SCacheObj *pCacheObj, SCacheDataNode
...
@@ -293,7 +294,7 @@ static SCacheDataNode *taosUpdateCacheImpl(SCacheObj *pCacheObj, SCacheDataNode
*/
*/
static
FORCE_INLINE
SCacheDataNode
*
taosAddToCacheImpl
(
SCacheObj
*
pCacheObj
,
const
char
*
key
,
size_t
keyLen
,
const
void
*
pData
,
static
FORCE_INLINE
SCacheDataNode
*
taosAddToCacheImpl
(
SCacheObj
*
pCacheObj
,
const
char
*
key
,
size_t
keyLen
,
const
void
*
pData
,
size_t
dataSize
,
uint64_t
duration
)
{
size_t
dataSize
,
uint64_t
duration
)
{
SCacheDataNode
*
pNode
=
taosCreate
Hash
Node
(
key
,
keyLen
,
pData
,
dataSize
,
duration
);
SCacheDataNode
*
pNode
=
taosCreate
Cache
Node
(
key
,
keyLen
,
pData
,
dataSize
,
duration
);
if
(
pNode
==
NULL
)
{
if
(
pNode
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录