Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
知世而放
oceanbase
提交
8e5fcb68
O
oceanbase
项目概览
知世而放
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8e5fcb68
编写于
10月 25, 2022
作者:
O
obdev
提交者:
wangzelin.wzl
10月 25, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix memory out of bounds in to_cstring
上级
097cd3de
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
40 deletion
+25
-40
deps/oblib/src/lib/trace/ob_trace.cpp
deps/oblib/src/lib/trace/ob_trace.cpp
+7
-7
deps/oblib/src/lib/trace/ob_trace.h
deps/oblib/src/lib/trace/ob_trace.h
+17
-32
deps/oblib/src/lib/utility/ob_print_utils.h
deps/oblib/src/lib/utility/ob_print_utils.h
+1
-1
未找到文件。
deps/oblib/src/lib/trace/ob_trace.cpp
浏览文件 @
8e5fcb68
...
@@ -255,12 +255,12 @@ int UUID::deserialize(const char* buf, const int64_t buf_len, int64_t& pos)
...
@@ -255,12 +255,12 @@ int UUID::deserialize(const char* buf, const int64_t buf_len, int64_t& pos)
int
to_string_and_strip
(
const
char
*
str
,
const
int64_t
length
,
char
*
buf
,
const
int64_t
buf_len
,
int64_t
&
pos
)
int
to_string_and_strip
(
const
char
*
str
,
const
int64_t
length
,
char
*
buf
,
const
int64_t
buf_len
,
int64_t
&
pos
)
{
{
int
ret
=
OB_SUCCESS
;
int
ret
=
OB_SUCCESS
;
char
from
[]
=
"
\"\n\r\\
"
;
char
from
[]
=
"
\"\n\r\\
\t
"
;
const
char
*
to
[]
=
{
"
\\\"
"
,
"
\\
n"
,
"
\\
r"
,
"
\\\\
"
};
const
char
*
to
[]
=
{
"
\\\"
"
,
"
\\
n"
,
"
\\
r"
,
"
\\\\
"
,
" "
};
buf
[
pos
++
]
=
'\"'
;
buf
[
pos
++
]
=
'\"'
;
for
(
auto
j
=
0
;
j
<
length
&&
str
[
j
];
++
j
)
{
for
(
auto
j
=
0
;
j
<
length
&&
str
[
j
];
++
j
)
{
bool
conv
=
false
;
bool
conv
=
false
;
for
(
auto
i
=
0
;
i
<
4
;
++
i
)
{
for
(
auto
i
=
0
;
i
<
sizeof
(
from
)
-
1
;
++
i
)
{
if
(
from
[
i
]
==
str
[
j
])
{
if
(
from
[
i
]
==
str
[
j
])
{
for
(
const
char
*
toc
=
to
[
i
];
*
toc
;
++
toc
)
{
for
(
const
char
*
toc
=
to
[
i
];
*
toc
;
++
toc
)
{
if
(
pos
<
buf_len
)
{
if
(
pos
<
buf_len
)
{
...
@@ -341,15 +341,15 @@ ObSpanCtx::ObSpanCtx()
...
@@ -341,15 +341,15 @@ ObSpanCtx::ObSpanCtx()
ObTrace
*
ObTrace
::
get_instance
()
ObTrace
*
ObTrace
::
get_instance
()
{
{
if
(
OB_ISNULL
(
save_buffer
))
{
if
(
OB_ISNULL
(
save_buffer
))
{
thread_local
char
*
default_tsi_buffer
=
(
char
*
)
GET_TSI
(
ByteBuf
<
8
*
DEFAULT_BUFFER_SIZE
>
);
thread_local
char
*
default_tsi_buffer
=
(
char
*
)
GET_TSI
(
ByteBuf
<
DEFAULT_BUFFER_SIZE
>
);
thread_local
char
default_tls_buffer
[
DEFAULT
_BUFFER_SIZE
];
thread_local
char
default_tls_buffer
[
MIN
_BUFFER_SIZE
];
struct
Guard
{
struct
Guard
{
Guard
(
char
*
buffer
,
int64_t
size
)
{
Guard
(
char
*
buffer
,
int64_t
size
)
{
IGNORE_RETURN
new
(
buffer
)
ObTrace
(
size
);
IGNORE_RETURN
new
(
buffer
)
ObTrace
(
size
);
}
}
};
};
thread_local
Guard
guard1
(
default_tsi_buffer
,
8
*
DEFAULT_BUFFER_SIZE
);
thread_local
Guard
guard1
(
default_tsi_buffer
,
DEFAULT_BUFFER_SIZE
);
thread_local
Guard
guard2
(
default_tls_buffer
,
1
*
DEFAULT
_BUFFER_SIZE
);
thread_local
Guard
guard2
(
default_tls_buffer
,
MIN
_BUFFER_SIZE
);
if
(
OB_ISNULL
(
default_tsi_buffer
))
{
if
(
OB_ISNULL
(
default_tsi_buffer
))
{
save_buffer
=
(
ObTrace
*
)
default_tls_buffer
;
save_buffer
=
(
ObTrace
*
)
default_tls_buffer
;
LIB_LOG
(
WARN
,
"tsi was nullptr"
);
LIB_LOG
(
WARN
,
"tsi was nullptr"
);
...
...
deps/oblib/src/lib/trace/ob_trace.h
浏览文件 @
8e5fcb68
...
@@ -209,7 +209,7 @@ struct ObSpanCtx final : public common::ObDLinkBase<ObSpanCtx>
...
@@ -209,7 +209,7 @@ struct ObSpanCtx final : public common::ObDLinkBase<ObSpanCtx>
struct
ObTrace
struct
ObTrace
{
{
static
constexpr
uint64_t
MAGIC_CODE
=
0x1234567887654321ul
;
static
constexpr
uint64_t
MAGIC_CODE
=
0x1234567887654321ul
;
static
constexpr
int64_t
DEFAULT_BUFFER_SIZE
=
(
1L
<<
1
3
);
static
constexpr
int64_t
DEFAULT_BUFFER_SIZE
=
(
1L
<<
1
6
);
static
constexpr
int64_t
MIN_BUFFER_SIZE
=
(
1L
<<
13
);
static
constexpr
int64_t
MIN_BUFFER_SIZE
=
(
1L
<<
13
);
static
ObTrace
*
get_instance
();
static
ObTrace
*
get_instance
();
static
void
set_trace_buffer
(
void
*
buffer
,
int64_t
buffer_size
);
static
void
set_trace_buffer
(
void
*
buffer
,
int64_t
buffer_size
);
...
@@ -273,46 +273,31 @@ struct ObTrace
...
@@ -273,46 +273,31 @@ struct ObTrace
bool
append_tag
(
ObTagType
tag_type
,
const
T
&
value
)
bool
append_tag
(
ObTagType
tag_type
,
const
T
&
value
)
{
{
int
ret
=
false
;
int
ret
=
false
;
ObString
v
(
""
);
if
(
OB_ISNULL
(
value
.
ptr
()))
{
if
(
OB_ISNULL
(
value
.
ptr
()))
{
// do nothing
// do nothing
}
else
{
}
else
{
auto
l
=
value
.
length
();
v
=
value
;
if
(
offset_
+
sizeof
(
ObTagCtx
<
void
*>
)
+
l
+
1
-
sizeof
(
void
*
)
>=
buffer_size_
)
{
}
// do nothing
auto
l
=
v
.
length
();
}
else
{
if
(
offset_
+
sizeof
(
ObTagCtx
<
void
*>
)
+
l
+
1
-
sizeof
(
void
*
)
>=
buffer_size_
)
{
ObTagCtx
<
void
*>*
tag
=
new
(
data_
+
offset_
)
ObTagCtx
<
void
*>
;
// do nothing
tag
->
next_
=
last_active_span_
->
tags_
;
}
else
{
last_active_span_
->
tags_
=
tag
;
ObTagCtx
<
void
*>*
tag
=
new
(
data_
+
offset_
)
ObTagCtx
<
void
*>
;
tag
->
tag_type_
=
tag_type
;
tag
->
next_
=
last_active_span_
->
tags_
;
memcpy
(
&
(
tag
->
data_
),
value
.
ptr
(),
l
);
last_active_span_
->
tags_
=
tag
;
offset_
+=
(
sizeof
(
ObTagCtx
<
void
*>
)
+
l
+
1
-
sizeof
(
void
*
));
tag
->
tag_type_
=
tag_type
;
data_
[
offset_
-
1
]
=
'\0'
;
memcpy
(
&
(
tag
->
data_
),
v
.
ptr
(),
l
);
ret
=
true
;
offset_
+=
(
sizeof
(
ObTagCtx
<
void
*>
)
+
l
+
1
-
sizeof
(
void
*
));
}
data_
[
offset_
-
1
]
=
'\0'
;
ret
=
true
;
}
}
return
ret
;
return
ret
;
}
}
template
<
class
T
,
typename
std
::
enable_if
<
std
::
is_convertible
<
T
,
const
char
*
>
::
value
,
bool
>::
type
=
true
>
template
<
class
T
,
typename
std
::
enable_if
<
std
::
is_convertible
<
T
,
const
char
*
>
::
value
,
bool
>::
type
=
true
>
bool
append_tag
(
ObTagType
tag_type
,
const
T
&
value
)
bool
append_tag
(
ObTagType
tag_type
,
const
T
&
value
)
{
{
int
ret
=
false
;
return
append_tag
(
tag_type
,
OB_ISNULL
(
value
)
?
ObString
(
""
)
:
ObString
(
value
));
if
(
OB_ISNULL
(
value
))
{
// do nothing
}
else
{
auto
l
=
strlen
(
value
);
if
(
offset_
+
sizeof
(
ObTagCtx
<
void
*>
)
+
l
+
1
-
sizeof
(
void
*
)
>=
buffer_size_
)
{
// do nothing
}
else
{
ObTagCtx
<
void
*>*
tag
=
new
(
data_
+
offset_
)
ObTagCtx
<
void
*>
;
tag
->
next_
=
last_active_span_
->
tags_
;
last_active_span_
->
tags_
=
tag
;
tag
->
tag_type_
=
tag_type
;
memcpy
(
&
(
tag
->
data_
),
value
,
l
+
1
);
offset_
+=
(
sizeof
(
ObTagCtx
<
void
*>
)
+
l
+
1
-
sizeof
(
void
*
));
ret
=
true
;
}
}
return
ret
;
}
}
private:
private:
bool
check_magic
()
{
return
MAGIC_CODE
==
magic_code_
;
}
bool
check_magic
()
{
return
MAGIC_CODE
==
magic_code_
;
}
...
...
deps/oblib/src/lib/utility/ob_print_utils.h
浏览文件 @
8e5fcb68
...
@@ -202,7 +202,7 @@ public:
...
@@ -202,7 +202,7 @@ public:
private:
private:
BufList
list_
;
BufList
list_
;
int64_t
level_
;
int64_t
level_
;
in
t
idx_
;
uint64_
t
idx_
;
};
};
template
<
typename
T
>
template
<
typename
T
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录