From e284b2dfc07c1639d85a330ab165f127d6b79e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Nordstr=C3=B6m?= Date: Wed, 11 Nov 2020 22:46:24 +0100 Subject: [PATCH] Fix uninitialized variable in data node validation Initialize a boolean variable used to check for a compatible extension on a data node. Leaving it uninitialized might lead to a potential read of a garbage value and unpredictible behavior. --- tsl/src/data_node.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tsl/src/data_node.c b/tsl/src/data_node.c index dc12a9b46..dde72783e 100644 --- a/tsl/src/data_node.c +++ b/tsl/src/data_node.c @@ -559,7 +559,7 @@ connect_for_bootstrapping(const char *node_name, const char *const host, int32 p return remote_connection_open_with_options_nothrow(node_name, node_options); } -/** +/* * Validate that compatible extension is available on the data node. * * We check all available extension versions. Since we are connected to @@ -573,9 +573,12 @@ connect_for_bootstrapping(const char *node_name, const char *const host, int32 p static void data_node_validate_extension_availability(TSConnection *conn) { - bool compatible; + StringInfo concat_versions = makeStringInfo(); + bool compatible = false; + PGresult *res; + int i; - PGresult *res = + res = remote_connection_execf(conn, "SELECT version FROM pg_available_extension_versions WHERE name = " "%s AND version ~ '\\d+.\\d+.\\d+.*' ORDER BY version DESC", @@ -593,11 +596,10 @@ data_node_validate_extension_availability(TSConnection *conn) Assert(PQnfields(res) == 1); - int i; - StringInfo concat_versions = makeStringInfo(); - bool old_version; for (i = 0; i < PQntuples(res); i++) { + bool old_version = false; + appendStringInfo(concat_versions, "%s, ", PQgetvalue(res, i, 0)); compatible = dist_util_is_compatible_version(PQgetvalue(res, i, 0), TIMESCALEDB_VERSION,