diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2010-06-30 18:10:23 +0000 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2010-06-30 18:10:23 +0000 |
commit | 350ab443beba3ce8a7ddf2090a3694de330f6bb3 (patch) | |
tree | f5661b619afb74b112da4696a5dfafe1f3e421af /src/backend/tcop/fastpath.c | |
parent | 71a4d5c642bf378bf85e5b6e352db3d6e47578e5 (diff) | |
download | postgresql-350ab443beba3ce8a7ddf2090a3694de330f6bb3.tar.gz postgresql-350ab443beba3ce8a7ddf2090a3694de330f6bb3.zip |
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.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c index 75e4791546e..6d224478734 100644 --- a/src/backend/tcop/fastpath.c +++ b/src/backend/tcop/fastpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.103 2010/02/14 18:42:15 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.104 2010/06/30 18:10:23 heikki Exp $ * * NOTES * This cruft is the server side of PQfn. @@ -29,6 +29,7 @@ #include "tcop/fastpath.h" #include "tcop/tcopprot.h" #include "utils/acl.h" +#include "utils/fmgroids.h" #include "utils/lsyscache.h" #include "utils/snapmgr.h" #include "utils/syscache.h" @@ -348,6 +349,16 @@ HandleFunctionRequest(StringInfo msgBuf) get_func_name(fid)); /* + * Restrict access to pg_get_expr(). This reflects the hack in + * transformFuncCall() in parse_expr.c, see comments there 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. */ InitFunctionCallInfoData(fcinfo, &fip->flinfo, 0, NULL, NULL); |