Skip to content

Commit 654e006

Browse files
committed
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.
1 parent c0aa210 commit 654e006

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/utils/adt/ruleutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ pg_get_viewdef_worker(Oid viewoid, int prettyFlags, int wrapColumn)
483483
* Get the pg_rewrite tuple for the view's SELECT rule
484484
*/
485485
args[0] = ObjectIdGetDatum(viewoid);
486-
args[1] = PointerGetDatum(ViewSelectRuleName);
486+
args[1] = DirectFunctionCall1(namein, CStringGetDatum(ViewSelectRuleName));
487487
nulls[0] = ' ';
488488
nulls[1] = ' ';
489489
spirc = SPI_execute_plan(plan_getviewrule, args, nulls, true, 2);

0 commit comments

Comments
 (0)