aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2013-11-23 07:25:37 -0500
committerPeter Eisentraut <peter_e@gmx.net>2013-11-23 07:30:16 -0500
commit0f8ff3e467b2b52e8c0c44b01a1f9a4495949ba1 (patch)
treef497893a0fee6d0b1ac947de564da9b879158797 /src/backend/utils/adt/ruleutils.c
parent6bc68af1dc29db9afc49e77f70de0dec7653c8e5 (diff)
downloadpostgresql-0f8ff3e467b2b52e8c0c44b01a1f9a4495949ba1.tar.gz
postgresql-0f8ff3e467b2b52e8c0c44b01a1f9a4495949ba1.zip
Avoid potential buffer overflow crash
A pointer to a C string was treated as a pointer to a "name" datum and passed to SPI_execute_plan(). This pointer would then end up being passed through datumCopy(), which would try to copy the entire 64 bytes of name data, thus running past the end of the C string. Fix by converting the string to a proper name structure. Found by LLVM AddressSanitizer.
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index fbade837464..ff983cca5d8 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -633,7 +633,7 @@ pg_get_viewdef_worker(Oid viewoid, int prettyFlags, int wrapColumn)
* Get the pg_rewrite tuple for the view's SELECT rule
*/
args[0] = ObjectIdGetDatum(viewoid);
- args[1] = PointerGetDatum(ViewSelectRuleName);
+ args[1] = DirectFunctionCall1(namein, CStringGetDatum(ViewSelectRuleName));
nulls[0] = ' ';
nulls[1] = ' ';
spirc = SPI_execute_plan(plan_getviewrule, args, nulls, true, 2);