Permalink
Browse files

- Modify getNamespaceOidFromFunctionOid() so that it finds the namesp…

…ace of

  the handler function for the language of the called function, rather than
  the namespace of the called funciton
- Add REVOKE execute to public for install_rcmd to fix security issue.
  • Loading branch information...
1 parent 0e7fa2e commit ccf586fd74e66a5c19d7843e96043ec7abcfb464 jconway committed Sep 17, 2006
Showing with 32 additions and 6 deletions.
  1. +32 −6 plr.c
View
38 plr.c
@@ -1387,23 +1387,49 @@ fetchArgNames(HeapTuple procTup, int nargs)
/*
* getNamespaceOidFromFunctionOid - Returns the OID of the namespace for the
- * postgresql function with the OID equal to the input argument.
+ * language handler function for the postgresql function with the OID equal
+ * to the input argument.
*/
static Oid
getNamespaceOidFromFunctionOid(Oid fnOid)
{
- HeapTuple procTuple;
- Form_pg_proc procStruct;
- Oid nspOid;
+ HeapTuple procTuple;
+ HeapTuple langTuple;
+ Form_pg_proc procStruct;
+ Form_pg_language langStruct;
+ Oid langOid;
+ Oid hfnOid;
+ Oid nspOid;
- /* Lookup the pg_proc tuple by OID */
+ /* Lookup the pg_proc tuple for the called function by OID */
procTuple = SearchSysCache(PROCOID, ObjectIdGetDatum(fnOid), 0, 0, 0);
if (!HeapTupleIsValid(procTuple))
/* internal error */
elog(ERROR, "cache lookup failed for function %u", fnOid);
- procStruct = (Form_pg_proc)GETSTRUCT(procTuple);
+ procStruct = (Form_pg_proc) GETSTRUCT(procTuple);
+ langOid = procStruct->prolang;
+ ReleaseSysCache(procTuple);
+
+ /* Lookup the pg_language tuple by OID */
+ langTuple = SearchSysCache(LANGOID, ObjectIdGetDatum(langOid), 0, 0, 0);
+ if (!HeapTupleIsValid(langTuple))
+ /* internal error */
+ elog(ERROR, "cache lookup failed for language %u", langOid);
+
+ langStruct = (Form_pg_language) GETSTRUCT(langTuple);
+ hfnOid = langStruct->lanplcallfoid;
+ ReleaseSysCache(langTuple);
+
+ /* Lookup the pg_proc tuple for the language handler by OID */
+ procTuple = SearchSysCache(PROCOID, ObjectIdGetDatum(hfnOid), 0, 0, 0);
+
+ if (!HeapTupleIsValid(procTuple))
+ /* internal error */
+ elog(ERROR, "cache lookup failed for function %u", hfnOid);
+
+ procStruct = (Form_pg_proc) GETSTRUCT(procTuple);
nspOid = procStruct->pronamespace;
ReleaseSysCache(procTuple);

0 comments on commit ccf586f

Please sign in to comment.