Skip to content

Commit af9f7db

Browse files
committed
harden functions against search_path hijacking
1 parent 0a312a0 commit af9f7db

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

pg_column_tetris--0.1.0.sql

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ RETURNS TABLE (
6161
optimal_position int,
6262
padding_bytes text
6363
)
64-
LANGUAGE plpgsql VOLATILE AS $$
64+
LANGUAGE plpgsql VOLATILE
65+
SET search_path TO pg_catalog, pg_temp AS $$
6566
DECLARE
6667
v_offset int;
6768
v_align int;
@@ -266,7 +267,8 @@ $$;
266267

267268
CREATE FUNCTION column_tetris.validate(rel_oid oid)
268269
RETURNS void
269-
LANGUAGE plpgsql AS $$
270+
LANGUAGE plpgsql
271+
SET search_path TO pg_catalog, pg_temp AS $$
270272
DECLARE
271273
v_current_waste int := 0;
272274
v_optimal_waste int := 0;
@@ -471,7 +473,8 @@ $$;
471473

472474
CREATE FUNCTION column_tetris.ddl_check()
473475
RETURNS event_trigger
474-
LANGUAGE plpgsql AS $$
476+
LANGUAGE plpgsql
477+
SET search_path TO pg_catalog, pg_temp AS $$
475478
DECLARE
476479
r record;
477480
current_mode text;

0 commit comments

Comments
 (0)