postgres.git / summary / log / commit / refs
commit 240766a6ecbb2e523fe0a2a43feb949f6fe6521d
Author: Peter Eisentraut <peter_e@gmx.net>
Date: Sat Nov 23 12:25:37 2013 +0000
First released in: 9.4.0, 8.4.19, 9.0.15, 9.1.11, 9.2.6, 9.3.2
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.
src/backend/utils/adt/ruleutils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 344984abd5d..1969c41db78 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -428,7 +428,7 @@ pg_get_viewdef_worker(Oid viewoid, int prettyFlags)
* 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);
[parent: 122ba5dadf93]