Skip to content

Commit

Permalink
Fix return type of compressed_data_info
Browse files Browse the repository at this point in the history
The function `compressed_data_info` returns a record containing `name`
but copies the data from `cstring`. Since `heap_form_tuple` expects a
`name` value as source as well, it will copy too much data from the
source, leading to ASAN complaining about copying outside the allocated
range of data.
  • Loading branch information
mkindahl committed Aug 7, 2024
1 parent 83c073e commit ccf2e23
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions .unreleased/pr_7187
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes: #7187 Fix return type of compressed_data_info
2 changes: 1 addition & 1 deletion sql/pre_install/types.functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CREATE OR REPLACE FUNCTION _timescaledb_functions.compressed_data_recv(internal)
LANGUAGE C IMMUTABLE STRICT;

CREATE OR REPLACE FUNCTION _timescaledb_functions.compressed_data_info(_timescaledb_internal.compressed_data)
RETURNS TABLE (algorithm name, has_nulls bool)
RETURNS TABLE (algorithm cstring, has_nulls bool)
LANGUAGE C STRICT IMMUTABLE
AS '@MODULE_PATHNAME@', 'ts_compressed_data_info';

Expand Down
6 changes: 4 additions & 2 deletions sql/updates/latest-dev.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CREATE FUNCTION _timescaledb_functions.compressed_data_info(_timescaledb_internal.compressed_data)
RETURNS TABLE (algorithm name, has_nulls bool)
AS 'SELECT NULL,FALSE' LANGUAGE SQL STRICT IMMUTABLE SET search_path = pg_catalog, pg_temp;
RETURNS TABLE (algorithm cstring, has_nulls bool)
AS $$ SELECT ''::cstring,FALSE $$
LANGUAGE SQL STRICT IMMUTABLE
SET search_path = pg_catalog, pg_temp;

0 comments on commit ccf2e23

Please sign in to comment.