Skip to content

Commit f0e8304

Browse files
committed
Fixed security CVE_2020_14350. Added tests
1 parent 49da956 commit f0e8304

File tree

4 files changed

+91
-8
lines changed

4 files changed

+91
-8
lines changed

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ OBJS = src/shared_ispell.o
66
EXTENSION = shared_ispell
77
DATA = shared_ispell--1.1.0.sql
88

9-
REGRESS = shared_ispell
9+
REGRESS = security shared_ispell
1010

1111
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/postgresql.conf
1212

Diff for: expected/security.out

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
create type si_dicts_result as (dict_name VARCHAR, affix_name VARCHAR, words INT, affixes INT, bytes INT);
2+
create function shared_ispell_dicts( OUT dict_name VARCHAR, OUT affix_name VARCHAR, OUT words INT, OUT affixes INT, OUT bytes INT)
3+
returns SETOF record as $$
4+
declare
5+
qString varchar(4000);
6+
rec si_dicts_result;
7+
begin
8+
qString := 'select * from shared_ispell_dicts()';
9+
for rec in execute qString loop
10+
return NEXT;
11+
end loop;
12+
return;
13+
end
14+
$$ language plpgsql;
15+
create extension shared_ispell;
16+
ERROR: function "shared_ispell_dicts" already exists with same argument types
17+
drop extension if exists shared_ispell;
18+
NOTICE: extension "shared_ispell" does not exist, skipping
19+
drop type si_dicts_result;
20+
drop function shared_ispell_dicts;
21+
create type si_stoplists_result as (stop_name VARCHAR, words INT, bytes INT);
22+
create function shared_ispell_stoplists(OUT stop_name VARCHAR, OUT words INT, OUT bytes INT)
23+
returns SETOF record as $$
24+
declare
25+
rec si_stoplists_result;
26+
qString varchar(4000);
27+
begin
28+
qString := 'select * from shared_ispell_stoplists()';
29+
for rec in execute qString loop
30+
return NEXT;
31+
end loop;
32+
return;
33+
end
34+
$$ language plpgsql;
35+
create extension shared_ispell;
36+
ERROR: function "shared_ispell_stoplists" already exists with same argument types
37+
drop extension if exists shared_ispell;
38+
NOTICE: extension "shared_ispell" does not exist, skipping
39+
drop type si_stoplists_result;
40+
drop function shared_ispell_stoplists;

Diff for: shared_ispell--1.1.0.sql

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
CREATE OR REPLACE FUNCTION shared_ispell_init(internal)
1+
CREATE FUNCTION shared_ispell_init(internal)
22
RETURNS internal
33
AS 'MODULE_PATHNAME', 'dispell_init'
44
LANGUAGE C IMMUTABLE;
55

6-
CREATE OR REPLACE FUNCTION shared_ispell_lexize(internal,internal,internal,internal)
6+
CREATE FUNCTION shared_ispell_lexize(internal,internal,internal,internal)
77
RETURNS internal
88
AS 'MODULE_PATHNAME', 'dispell_lexize'
99
LANGUAGE C IMMUTABLE;
1010

11-
CREATE OR REPLACE FUNCTION shared_ispell_reset()
11+
CREATE FUNCTION shared_ispell_reset()
1212
RETURNS void
1313
AS 'MODULE_PATHNAME', 'dispell_reset'
1414
LANGUAGE C IMMUTABLE;
1515

16-
CREATE OR REPLACE FUNCTION shared_ispell_mem_used()
16+
CREATE FUNCTION shared_ispell_mem_used()
1717
RETURNS integer
1818
AS 'MODULE_PATHNAME', 'dispell_mem_used'
1919
LANGUAGE C IMMUTABLE;
2020

21-
CREATE OR REPLACE FUNCTION shared_ispell_mem_available()
21+
CREATE FUNCTION shared_ispell_mem_available()
2222
RETURNS integer
2323
AS 'MODULE_PATHNAME', 'dispell_mem_available'
2424
LANGUAGE C IMMUTABLE;
2525

26-
CREATE OR REPLACE FUNCTION shared_ispell_dicts( OUT dict_name VARCHAR, OUT affix_name VARCHAR, OUT words INT, OUT affixes INT, OUT bytes INT)
26+
CREATE FUNCTION shared_ispell_dicts( OUT dict_name VARCHAR, OUT affix_name VARCHAR, OUT words INT, OUT affixes INT, OUT bytes INT)
2727
RETURNS SETOF record
2828
AS 'MODULE_PATHNAME', 'dispell_list_dicts'
2929
LANGUAGE C IMMUTABLE;
3030

31-
CREATE OR REPLACE FUNCTION shared_ispell_stoplists( OUT stop_name VARCHAR, OUT words INT, OUT bytes INT)
31+
CREATE FUNCTION shared_ispell_stoplists( OUT stop_name VARCHAR, OUT words INT, OUT bytes INT)
3232
RETURNS SETOF record
3333
AS 'MODULE_PATHNAME', 'dispell_list_stoplists'
3434
LANGUAGE C IMMUTABLE;

Diff for: sql/security.sql

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
create type si_dicts_result as (dict_name VARCHAR, affix_name VARCHAR, words INT, affixes INT, bytes INT);
2+
3+
create function shared_ispell_dicts( OUT dict_name VARCHAR, OUT affix_name VARCHAR, OUT words INT, OUT affixes INT, OUT bytes INT)
4+
returns SETOF record as $$
5+
declare
6+
qString varchar(4000);
7+
rec si_dicts_result;
8+
begin
9+
qString := 'select * from shared_ispell_dicts()';
10+
for rec in execute qString loop
11+
return NEXT;
12+
end loop;
13+
return;
14+
end
15+
$$ language plpgsql;
16+
17+
create extension shared_ispell;
18+
19+
drop extension if exists shared_ispell;
20+
drop type si_dicts_result;
21+
drop function shared_ispell_dicts;
22+
23+
create type si_stoplists_result as (stop_name VARCHAR, words INT, bytes INT);
24+
25+
create function shared_ispell_stoplists(OUT stop_name VARCHAR, OUT words INT, OUT bytes INT)
26+
returns SETOF record as $$
27+
declare
28+
rec si_stoplists_result;
29+
qString varchar(4000);
30+
begin
31+
qString := 'select * from shared_ispell_stoplists()';
32+
for rec in execute qString loop
33+
return NEXT;
34+
end loop;
35+
return;
36+
end
37+
$$ language plpgsql;
38+
39+
create extension shared_ispell;
40+
41+
drop extension if exists shared_ispell;
42+
drop type si_stoplists_result;
43+
drop function shared_ispell_stoplists;

0 commit comments

Comments
 (0)