OSDN Git Service

Install a data-type-based solution for protecting pg_get_expr().
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 3 Sep 2010 01:34:55 +0000 (01:34 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 3 Sep 2010 01:34:55 +0000 (01:34 +0000)
commit303696c3b47e6719e983e93da5896ddc4a2e0dbb
tree0cf979aeaf94f5f4c45948c3db78755d08dde5a6
parent8ab6a6b4562efcd9f320353d5438fdbe10dbf9c5
Install a data-type-based solution for protecting pg_get_expr().

Since the code underlying pg_get_expr() is not secure against malformed
input, and can't practically be made so, we need to prevent miscreants
from feeding arbitrary data to it.  We can do this securely by declaring
pg_get_expr() to take a new datatype "pg_node_tree" and declaring the
system catalog columns that hold nodeToString output to be of that type.
There is no way at SQL level to create a non-null value of type pg_node_tree.
Since the backend-internal operations that fill those catalog columns
operate below the SQL level, they are oblivious to the datatype relabeling
and don't need any changes.
19 files changed:
doc/src/sgml/catalogs.sgml
doc/src/sgml/func.sgml
src/backend/bootstrap/bootstrap.c
src/backend/utils/adt/pseudotypes.c
src/include/catalog/catversion.h
src/include/catalog/genbki.h
src/include/catalog/pg_attrdef.h
src/include/catalog/pg_cast.h
src/include/catalog/pg_constraint.h
src/include/catalog/pg_index.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_rewrite.h
src/include/catalog/pg_trigger.h
src/include/catalog/pg_type.h
src/include/utils/builtins.h
src/test/regress/expected/opr_sanity.out
src/test/regress/expected/type_sanity.out
src/test/regress/sql/opr_sanity.sql
src/test/regress/sql/type_sanity.sql