summaryrefslogtreecommitdiff
path: root/src/backend/tcop/fastpath.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-06-30 18:11:43 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-06-30 18:11:43 +0000
commitfa8ccf59faaec5c026e3721642487cab6fa3b34f (patch)
tree9e7ccc7ffb59aa9efe7806459ea9b7ef0876cda8 /src/backend/tcop/fastpath.c
parent873b9b8a3d5d57520484fabef680e2cbddc58760 (diff)
stringToNode() and deparse_expression_pretty() crash on invalid input,
but we have nevertheless exposed them to users via pg_get_expr(). It would be too much maintenance effort to rigorously check the input, so put a hack in place instead to restrict pg_get_expr() so that the argument must come from one of the system catalog columns known to contain valid expressions. Per report from Rushabh Lathia. Backpatch to 7.4 which is the oldest supported version at the moment.
Diffstat (limited to 'src/backend/tcop/fastpath.c')
-rw-r--r--src/backend/tcop/fastpath.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index 0a5016932c5..b7cd204ed2b 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.69 2003/09/25 06:58:02 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.69.2.1 2010/06/30 18:11:43 heikki Exp $
*
* NOTES
* This cruft is the server side of PQfn.
@@ -27,6 +27,7 @@
#include "mb/pg_wchar.h"
#include "tcop/fastpath.h"
#include "utils/acl.h"
+#include "utils/fmgroids.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
#include "utils/tqual.h"
@@ -340,6 +341,16 @@ HandleFunctionRequest(StringInfo msgBuf)
SetQuerySnapshot();
/*
+ * Restrict access to pg_get_expr(). This reflects the hack in
+ * transformExpr() in parse_expr.c, see comments there on FuncCall for an
+ * explanation.
+ */
+ if ((fid == F_PG_GET_EXPR || fid == F_PG_GET_EXPR_EXT) && !superuser())
+ ereport(ERROR,
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ errmsg("argument to pg_get_expr() must come from system catalogs")));
+
+ /*
* Prepare function call info block and insert arguments.
*/
MemSet(&fcinfo, 0, sizeof(fcinfo));