aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/enum.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-02-04 16:25:15 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2013-02-04 16:25:15 -0500
commit1881634820603e8212983ebd4825d4f4b4988789 (patch)
tree37270e23f8a3694d5d8a60df6a30248ac6304cc8 /src/backend/utils/adt/enum.c
parent51d0efe8a2bd6c64f245fcc60a2fba07b9e3b6f6 (diff)
downloadpostgresql-1881634820603e8212983ebd4825d4f4b4988789.tar.gz
postgresql-1881634820603e8212983ebd4825d4f4b4988789.zip
Prevent execution of enum_recv() from SQL.
This function was misdeclared to take cstring when it should take internal. This at least allows crashing the server, and in principle an attacker might be able to use the function to examine the contents of server memory. The correct fix is to adjust the system catalog contents (and fix the regression tests that should have caught this but failed to). However, asking users to correct the catalog contents in existing installations is a pain, so as a band-aid fix for the back branches, install a check in enum_recv() to make it throw error if called with a cstring argument. We will later revert this in HEAD in favor of correcting the catalogs. Our thanks to Sumit Soni (via Secunia SVCRP) for reporting this issue. Security: CVE-2013-0255
Diffstat (limited to 'src/backend/utils/adt/enum.c')
-rw-r--r--src/backend/utils/adt/enum.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c
index 8f65c84d305..2e026c80091 100644
--- a/src/backend/utils/adt/enum.c
+++ b/src/backend/utils/adt/enum.c
@@ -17,6 +17,7 @@
#include "access/heapam.h"
#include "catalog/indexing.h"
#include "catalog/pg_enum.h"
+#include "catalog/pg_type.h"
#include "fmgr.h"
#include "libpq/pqformat.h"
#include "utils/array.h"
@@ -104,6 +105,10 @@ enum_recv(PG_FUNCTION_ARGS)
char *name;
int nbytes;
+ /* guard against pre-9.3 misdeclaration of enum_recv */
+ if (get_fn_expr_argtype(fcinfo->flinfo, 0) == CSTRINGOID)
+ elog(ERROR, "invalid argument for enum_recv");
+
name = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes);
/* must check length to prevent Assert failure within SearchSysCache */