Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite3f1c24

Browse files
committed
Fix crasher bugs in previous commit
ALTER DEFAULT PRIVILEGES was trying to decode the list of roles in theFOR clause as a list of names rather than of RoleSpecs; and the INclause in CREATE ROLE was doing the same thing. This was evidenced bycrashes on some buildfarm machines, though on my platform this doesn'tcause a failure by mere chance; I can reproduce the failures only byadding some padding in struct RoleSpecs.Fix by dereferencing those lists as being of RoleSpecs, not stringValues.
1 parent31eae60 commite3f1c24

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

‎src/backend/catalog/aclchk.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -858,9 +858,9 @@ ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt)
858858
GrantStmt*action=stmt->action;
859859
InternalDefaultACLiacls;
860860
ListCell*cell;
861-
List*rolenames=NIL;
861+
List*rolespecs=NIL;
862862
List*nspnames=NIL;
863-
DefElem*drolenames=NULL;
863+
DefElem*drolespecs=NULL;
864864
DefElem*dnspnames=NULL;
865865
AclModeall_privileges;
866866
constchar*errormsg;
@@ -880,20 +880,20 @@ ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt)
880880
}
881881
elseif (strcmp(defel->defname,"roles")==0)
882882
{
883-
if (drolenames)
883+
if (drolespecs)
884884
ereport(ERROR,
885885
(errcode(ERRCODE_SYNTAX_ERROR),
886886
errmsg("conflicting or redundant options")));
887-
drolenames=defel;
887+
drolespecs=defel;
888888
}
889889
else
890890
elog(ERROR,"option \"%s\" not recognized",defel->defname);
891891
}
892892

893893
if (dnspnames)
894894
nspnames= (List*)dnspnames->arg;
895-
if (drolenames)
896-
rolenames= (List*)drolenames->arg;
895+
if (drolespecs)
896+
rolespecs= (List*)drolespecs->arg;
897897

898898
/* Prepare the InternalDefaultACL representation of the statement */
899899
/* roleid to be filled below */
@@ -996,7 +996,7 @@ ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt)
996996
}
997997
}
998998

999-
if (rolenames==NIL)
999+
if (rolespecs==NIL)
10001000
{
10011001
/* Set permissions for myself */
10021002
iacls.roleid=GetUserId();
@@ -1008,11 +1008,11 @@ ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt)
10081008
/* Look up the role OIDs and do permissions checks */
10091009
ListCell*rolecell;
10101010

1011-
foreach(rolecell,rolenames)
1011+
foreach(rolecell,rolespecs)
10121012
{
1013-
char*rolename=strVal(lfirst(rolecell));
1013+
RoleSpec*rolespec=lfirst(rolecell);
10141014

1015-
iacls.roleid=get_role_oid(rolename, false);
1015+
iacls.roleid=get_rolespec_oid((Node*)rolespec, false);
10161016

10171017
/*
10181018
* We insist that calling user be a member of each target role. If

‎src/backend/commands/user.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,17 @@ CreateRole(CreateRoleStmt *stmt)
429429
*/
430430
foreach(item,addroleto)
431431
{
432-
char*oldrolename=strVal(lfirst(item));
433-
Oidoldroleid=get_role_oid(oldrolename, false);
432+
RoleSpec*oldrole=lfirst(item);
433+
HeapTupleoldroletup=get_rolespec_tuple((Node*)oldrole);
434+
Oidoldroleid=HeapTupleGetOid(oldroletup);
435+
char*oldrolename=NameStr(((Form_pg_authid)GETSTRUCT(oldroletup))->rolname);
434436

435437
AddRoleMems(oldrolename,oldroleid,
436438
list_make1(makeString(stmt->role)),
437439
list_make1_oid(roleid),
438440
GetUserId(), false);
441+
442+
ReleaseSysCache(oldroletup);
439443
}
440444

441445
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp