Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lihongda1002
oceanbase
提交
669b4d93
O
oceanbase
项目概览
lihongda1002
/
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,发现更多精彩内容 >>
提交
669b4d93
编写于
7月 04, 2022
作者:
O
obdev
提交者:
wangzelin.wzl
7月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CP] Fix core caused by out-of-bounds access to the question mark name array
上级
fa70d540
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
14 deletion
+40
-14
src/sql/parser/parse_node.c
src/sql/parser/parse_node.c
+34
-12
src/sql/parser/parse_node.h
src/sql/parser/parse_node.h
+4
-2
src/sql/parser/sql_parser_base.c
src/sql/parser/sql_parser_base.c
+2
-0
未找到文件。
src/sql/parser/parse_node.c
浏览文件 @
669b4d93
...
...
@@ -567,19 +567,41 @@ int64_t get_question_mark(ObQuestionMarkCtx* ctx, void* malloc_pool, const char*
if
(
OB_UNLIKELY
(
NULL
==
ctx
||
NULL
==
name
))
{
(
void
)
fprintf
(
stderr
,
"ERROR question mark ctx or name is NULL
\n
"
);
}
else
{
bool
valid_name
=
true
;
for
(
int64_t
i
=
0
;
valid_name
&&
-
1
==
idx
&&
i
<
ctx
->
count_
;
++
i
)
{
if
(
NULL
==
ctx
->
name_
[
i
])
{
(
void
)
fprintf
(
stderr
,
"ERROR name_ in question mark ctx is null
\n
"
);
valid_name
=
false
;
}
else
if
(
0
==
STRCASECMP
(
ctx
->
name_
[
i
],
name
))
{
idx
=
i
;
}
if
(
NULL
==
ctx
->
name_
&&
0
==
ctx
->
capacity_
)
{
ctx
->
capacity_
=
MAX_QUESTION_MARK
;
// the errocde will be ignored here. TO BE FIXED.
ctx
->
name_
=
(
char
**
)
parse_malloc
(
sizeof
(
char
*
)
*
MAX_QUESTION_MARK
,
malloc_pool
);
}
if
(
-
1
==
idx
&&
valid_name
)
{
int64_t
len
=
0
;
ctx
->
name_
[
ctx
->
count_
]
=
parse_strdup
(
name
,
malloc_pool
,
&
len
);
idx
=
ctx
->
count_
++
;
if
(
ctx
->
name_
!=
NULL
)
{
bool
valid_name
=
true
;
for
(
int64_t
i
=
0
;
valid_name
&&
-
1
==
idx
&&
i
<
ctx
->
count_
;
++
i
)
{
if
(
NULL
==
ctx
->
name_
[
i
])
{
(
void
)
fprintf
(
stderr
,
"ERROR name_ in question mark ctx is null
\n
"
);
valid_name
=
false
;
}
else
if
(
0
==
STRCASECMP
(
ctx
->
name_
[
i
],
name
))
{
idx
=
i
;
}
}
if
(
-
1
==
idx
&&
valid_name
)
{
if
(
ctx
->
count_
>=
ctx
->
capacity_
)
{
void
*
buf
=
parse_malloc
(
sizeof
(
char
*
)
*
(
ctx
->
capacity_
*
2
),
malloc_pool
);
if
(
OB_UNLIKELY
(
NULL
==
buf
))
{
ctx
->
name_
=
NULL
;
(
void
)
printf
(
"ERROR malloc memory failed
\n
"
);
}
else
{
MEMCPY
(
buf
,
ctx
->
name_
,
sizeof
(
char
*
)
*
ctx
->
capacity_
);
ctx
->
capacity_
*=
2
;
ctx
->
name_
=
(
char
**
)
buf
;
}
}
if
(
ctx
->
name_
!=
NULL
)
{
int64_t
len
=
0
;
ctx
->
name_
[
ctx
->
count_
]
=
parse_strdup
(
name
,
malloc_pool
,
&
len
);
idx
=
ctx
->
count_
++
;
}
}
}
else
{
(
void
)
fprintf
(
stderr
,
"ERROR question mark name buffer is null
\n
"
);
}
}
return
idx
;
...
...
src/sql/parser/parse_node.h
浏览文件 @
669b4d93
...
...
@@ -178,9 +178,11 @@ typedef struct _PLParseInfo {
#define MAX_QUESTION_MARK 128
typedef
struct
_ObQuestionMarkCtx
{
char
*
name_
[
MAX_QUESTION_MARK
];
typedef
struct
_ObQuestionMarkCtx
{
char
**
name_
;
int
count_
;
int
capacity_
;
bool
by_ordinal_
;
bool
by_name_
;
}
ObQuestionMarkCtx
;
...
...
src/sql/parser/sql_parser_base.c
浏览文件 @
669b4d93
...
...
@@ -64,6 +64,8 @@ int parse_reset(ParseResult* p)
p
->
question_mark_ctx_
.
count_
=
0
;
p
->
question_mark_ctx_
.
by_ordinal_
=
false
;
p
->
question_mark_ctx_
.
by_name_
=
false
;
p
->
question_mark_ctx_
.
name_
=
NULL
;
p
->
question_mark_ctx_
.
capacity_
=
0
;
p
->
sql_mode_
=
0
;
p
->
has_encount_comment_
=
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录