The following issues were found

tsl/test/sql/remote_stmt_params.sql
1 issues
Syntax error at or near "\"
Syntax error

Line: 5 Column: 1

              -- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.

\c :TEST_DBNAME :ROLE_SUPERUSER

CREATE OR REPLACE FUNCTION _timescaledb_internal.test_stmt_params_format(binary BOOL)
RETURNS VOID
AS :TSL_MODULE_PATHNAME, 'ts_test_stmt_params_format'
LANGUAGE C STRICT;

            

Reported by SQLint.

src/catalog.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 1251 Column: 2 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              
typedef struct CatalogDatabaseInfo
{
	char database_name[NAMEDATALEN];
	Oid database_id;
	Oid schema_id;
	Oid owner_uid;
} CatalogDatabaseInfo;


            

Reported by FlawFinder.

test/src/net/test_conn.c
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 22 Column: 2 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              Datum
ts_test_conn(PG_FUNCTION_ARGS)
{
	char response[MAX_RESULT_SIZE];
	Connection *conn;
	int ret;
	int port = 80;
#ifdef TS_USE_OPENSSL
	int ssl_port = 443;

            

Reported by FlawFinder.

test/src/bgw/scheduler_mock.c
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 51 Column: 14 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              	_MAX_TEST_JOB_TYPE
} TestJobType;

static const char *test_job_type_names[_MAX_TEST_JOB_TYPE] = {
	[TEST_JOB_TYPE_JOB_1] = "bgw_test_job_1",
	[TEST_JOB_TYPE_JOB_2_ERROR] = "bgw_test_job_2_error",
	[TEST_JOB_TYPE_JOB_3_LONG] = "bgw_test_job_3_long",
	[TEST_JOB_TYPE_JOB_4] = "bgw_test_job_4",
};

            

Reported by FlawFinder.

tsl/src/async_append.c
1 issues
Uninitialized variable: num_child_plans
Error

Line: 196 CWE codes: 908

              	else
		elog(ERROR, "unexpected child node %u of AsyncAppend", nodeTag(state->subplan_state));

	for (i = 0; i < num_child_plans; i++)
		dn_plans = lappend(dn_plans, find_data_node_scan_state_child(child_plans[i]));

	return dn_plans;
}


            

Reported by Cppcheck.

src/bgw/scheduler.c
1 issues
strlen - Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected)
Security

Line: 131 Column: 9 CWE codes: 126

              	strlcpy(worker.bgw_library_name, ts_extension_get_so_name(), BGW_MAXLEN);
	strlcpy(worker.bgw_function_name, function, BGW_MAXLEN);

	Assert(strlen(extra) < BGW_EXTRALEN);
	strlcpy(worker.bgw_extra, extra, BGW_EXTRALEN);

	/* handle needs to be allocated in long-lived memory context */
	MemoryContextSwitchTo(scheduler_mctx);
	if (!RegisterDynamicBackgroundWorker(&worker, &handle))

            

Reported by FlawFinder.

tsl/src/compression/array.c
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 267 Column: 2 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

              	dst_size -= sizes_bytes;

	Assert(dst_size == info->data.num_elements);
	memcpy(dst, info->data.data, info->data.num_elements);
	return dst + info->data.num_elements;
}

static ArrayCompressed *
array_compressed_from_serialization_info(ArrayCompressorSerializationInfo *info, Oid element_type)

            

Reported by FlawFinder.

tsl/src/compression/compression.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 24 Column: 2 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

               * number of compression algorithms.
 */
#define CompressedDataHeaderFields                                                                 \
	char vl_len_[4];                                                                               \
	uint8 compression_algorithm

typedef struct CompressedDataHeader
{
	CompressedDataHeaderFields;

            

Reported by FlawFinder.

test/sql/updates/setup.v7.sql
1 issues
Syntax error at or near "\"
Syntax error

Line: 5 Column: 1

              -- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.

\ir setup.v6.sql
\ir setup.multinode.sql

            

Reported by SQLint.

test/src/bgw/params.c
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 149 Column: 2 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

              
	SpinLockAcquire(&wrapper->mutex);

	memcpy(res, &wrapper->params, sizeof(TestParams));

	SpinLockRelease(&wrapper->mutex);

	if (do_close)
		params_close_wrapper(wrapper);

            

Reported by FlawFinder.