From 4a5e29522ebe8731b37148873cba39d835e7e0c7 Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Mon, 19 Dec 2022 23:29:33 +0100 Subject: [PATCH 3/4] pg_upgrade: Avoid storing query on the stack There is no use in snprintf'ing the query into a stack buffer since there are no parameters used. Make the code consistent and hardcode the query text in the query execution call instead. --- src/bin/pg_upgrade/tablespace.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/bin/pg_upgrade/tablespace.c b/src/bin/pg_upgrade/tablespace.c index 69cef7fa6b..f6af6d1be0 100644 --- a/src/bin/pg_upgrade/tablespace.c +++ b/src/bin/pg_upgrade/tablespace.c @@ -43,16 +43,13 @@ get_tablespace_paths(void) PGresult *res; int tblnum; int i_spclocation; - char query[QUERY_ALLOC]; - snprintf(query, sizeof(query), + res = executeQueryOrDie(conn, "SELECT pg_catalog.pg_tablespace_location(oid) AS spclocation " "FROM pg_catalog.pg_tablespace " "WHERE spcname != 'pg_default' AND " " spcname != 'pg_global'"); - res = executeQueryOrDie(conn, "%s", query); - if ((os_info.num_old_tablespaces = PQntuples(res)) != 0) os_info.old_tablespaces = (char **) pg_malloc(os_info.num_old_tablespaces * sizeof(char *)); -- 2.32.1 (Apple Git-133)