Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
2b5f049f
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2b5f049f
编写于
8月 14, 2003
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle double-quotes correctly in user names in ACL lists.
Christopher Kings-Lynne
上级
8e97f45f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
21 deletion
+40
-21
src/backend/utils/adt/acl.c
src/backend/utils/adt/acl.c
+31
-17
src/bin/pg_dump/dumputils.c
src/bin/pg_dump/dumputils.c
+9
-4
未找到文件。
src/backend/utils/adt/acl.c
浏览文件 @
2b5f049f
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.9
4 2003/08/04 02:40:04 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.9
5 2003/08/14 14:19:07 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -61,8 +61,8 @@ static AclMode convert_schema_priv_string(text *priv_type_text);
* RETURNS:
* the string position in 's' that points to the next non-space character
* in 's', after any quotes. Also:
* - loads the identifier into 'n
ame'. (If no identifier is found, 'name
'
* contains an empty string.)
name
must be NAMEDATALEN bytes.
* - loads the identifier into 'n
'. (If no identifier is found, 'n
'
* contains an empty string.)
'n'
must be NAMEDATALEN bytes.
*/
static
const
char
*
getid
(
const
char
*
s
,
char
*
n
)
...
...
@@ -74,7 +74,7 @@ getid(const char *s, char *n)
while
(
isspace
((
unsigned
char
)
*
s
))
s
++
;
/* This
test
had better match what putid() does, below */
/* This
code
had better match what putid() does, below */
for
(;
*
s
!=
'\0'
&&
(
isalnum
((
unsigned
char
)
*
s
)
||
...
...
@@ -84,18 +84,26 @@ getid(const char *s, char *n)
s
++
)
{
if
(
*
s
==
'"'
)
in_quotes
=
!
in_quotes
;
else
{
if
(
len
>=
NAMEDATALEN
-
1
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_NAME_TOO_LONG
),
errmsg
(
"identifier too long"
),
errdetail
(
"Identifier must be less than %d characters."
,
NAMEDATALEN
)));
n
[
len
++
]
=
*
s
;
/* safe to look at next char (could be '\0' though) */
if
(
*
(
s
+
1
)
!=
'"'
)
{
in_quotes
=
!
in_quotes
;
continue
;
}
/* it's an escaped double quote; skip the escaping char */
s
++
;
}
/* Add the character to the string */
if
(
len
>=
NAMEDATALEN
-
1
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_NAME_TOO_LONG
),
errmsg
(
"identifier too long"
),
errdetail
(
"Identifier must be less than %d characters."
,
NAMEDATALEN
)));
n
[
len
++
]
=
*
s
;
}
n
[
len
]
=
'\0'
;
while
(
isspace
((
unsigned
char
)
*
s
))
...
...
@@ -104,8 +112,9 @@ getid(const char *s, char *n)
}
/*
* Write a user or group Name at *p, surrounding it with double quotes if
* needed. There must be at least NAMEDATALEN+2 bytes available at *p.
* Write a user or group Name at *p, adding double quotes if needed.
* There must be at least (2*NAMEDATALEN)+2 bytes available at *p.
* This needs to be kept in sync with copyAclUserName in pg_dump/dumputils.c
*/
static
void
putid
(
char
*
p
,
const
char
*
s
)
...
...
@@ -125,7 +134,12 @@ putid(char *p, const char *s)
if
(
!
safe
)
*
p
++
=
'"'
;
for
(
src
=
s
;
*
src
;
src
++
)
{
/* A double quote character in a username is encoded as "" */
if
(
*
src
==
'"'
)
*
p
++
=
'"'
;
*
p
++
=
*
src
;
}
if
(
!
safe
)
*
p
++
=
'"'
;
*
p
=
'\0'
;
...
...
@@ -358,7 +372,7 @@ aclitemout(PG_FUNCTION_ARGS)
out
=
palloc
(
strlen
(
"group =/"
)
+
2
*
N_ACL_RIGHTS
+
2
*
(
NAMEDATALEN
+
2
)
+
2
*
(
2
*
NAMEDATALEN
+
2
)
+
1
);
p
=
out
;
...
...
src/bin/pg_dump/dumputils.c
浏览文件 @
2b5f049f
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/bin/pg_dump/dumputils.c,v 1.
8 2003/08/04 02:40:09 momjian
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/dumputils.c,v 1.
9 2003/08/14 14:19:11 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -557,23 +557,28 @@ static char *
copyAclUserName
(
PQExpBuffer
output
,
char
*
input
)
{
resetPQExpBuffer
(
output
);
while
(
*
input
&&
*
input
!=
'='
)
{
/* If user name isn't quoted, then just add it to the output buffer */
if
(
*
input
!=
'"'
)
appendPQExpBufferChar
(
output
,
*
input
++
);
else
{
/* Otherwise, it's a quoted username */
input
++
;
while
(
*
input
!=
'"'
)
/* Loop until we come across an unescaped quote */
while
(
!
(
*
input
==
'"'
&&
*
(
input
+
1
)
!=
'"'
))
{
if
(
*
input
==
'\0'
)
return
input
;
/* really a syntax error... */
/*
* There is no quoting convention here, thus we can't cope
* with usernames containing double quotes. Keep this
* Quoting convention is to escape " as "". Keep this
* code in sync with putid() in backend's acl.c.
*/
if
(
*
input
==
'"'
&&
*
(
input
+
1
)
==
'"'
)
input
++
;
appendPQExpBufferChar
(
output
,
*
input
++
);
}
input
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录