mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +03:00
fmgr_security_definer had better do a PG_TRY to ensure the outer userid
is restored on error exit.
This commit is contained in:
parent
c8196c87a7
commit
b62aa83f0e
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.84 2004/09/13 01:44:46 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.85 2004/10/01 20:39:54 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -794,7 +794,7 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
Datum result;
|
Datum result;
|
||||||
FmgrInfo *save_flinfo;
|
FmgrInfo *save_flinfo;
|
||||||
struct fmgr_security_definer_cache *fcache;
|
struct fmgr_security_definer_cache * volatile fcache;
|
||||||
AclId save_userid;
|
AclId save_userid;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
@ -821,14 +821,25 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
|
|||||||
fcache = fcinfo->flinfo->fn_extra;
|
fcache = fcinfo->flinfo->fn_extra;
|
||||||
|
|
||||||
save_flinfo = fcinfo->flinfo;
|
save_flinfo = fcinfo->flinfo;
|
||||||
fcinfo->flinfo = &fcache->flinfo;
|
|
||||||
|
|
||||||
save_userid = GetUserId();
|
save_userid = GetUserId();
|
||||||
|
|
||||||
|
PG_TRY();
|
||||||
|
{
|
||||||
|
fcinfo->flinfo = &fcache->flinfo;
|
||||||
SetUserId(fcache->userid);
|
SetUserId(fcache->userid);
|
||||||
|
|
||||||
result = FunctionCallInvoke(fcinfo);
|
result = FunctionCallInvoke(fcinfo);
|
||||||
|
}
|
||||||
|
PG_CATCH();
|
||||||
|
{
|
||||||
|
fcinfo->flinfo = save_flinfo;
|
||||||
SetUserId(save_userid);
|
SetUserId(save_userid);
|
||||||
|
PG_RE_THROW();
|
||||||
|
}
|
||||||
|
PG_END_TRY();
|
||||||
|
|
||||||
fcinfo->flinfo = save_flinfo;
|
fcinfo->flinfo = save_flinfo;
|
||||||
|
SetUserId(save_userid);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user