summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Vondra2017-07-29 16:54:59 +0000
committerTomas Vondra2018-10-12 12:54:20 +0000
commit5d892856f6733f3f2367c5d435cc2ee825b14cab (patch)
tree1b07606fb706ba7e37b3f1757ef3c265ff5b64a9
parentb86229ef81a5bcb793148b2352e5e50fcbd2fdd9 (diff)
Remove extra snprintf call in pg_tablespace_databases
The XL code did two function calls in the else branch, about like this: else /* Postgres-XC tablespaces also include node name in path */ sprintf(fctx->location, "pg_tblspc/%u/%s_%s", tablespaceOid, TABLESPACE_VERSION_DIRECTORY, PGXCNodeName); fctx->location = psprintf("pg_tblspc/%u/%s_%s", tablespaceOid, TABLESPACE_VERSION_DIRECTORY, PGXCNodeName); which is wrong, as only the first call is actually the else branch, the second call is executed unconditionally. In fact, the two calls attempt to construct the same location string, but the sprintf call assumes the 'fctx->location' string is already allocated. But it actually is not, so it's likely to cause a segfault. Fixed by removing the sprintf() call, keeping just the psprintf() one. Noticed thanks to GCC 6.3 complaining about incorrect indentation. Backpatch to XL 9.5.
-rw-r--r--src/backend/utils/adt/misc.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 37eabe4af7..cd3a0a59d6 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -282,8 +282,6 @@ pg_tablespace_databases(PG_FUNCTION_ARGS)
else
#ifdef PGXC
/* Postgres-XC tablespaces also include node name in path */
- sprintf(fctx->location, "pg_tblspc/%u/%s_%s", tablespaceOid,
- TABLESPACE_VERSION_DIRECTORY, PGXCNodeName);
fctx->location = psprintf("pg_tblspc/%u/%s_%s", tablespaceOid,
TABLESPACE_VERSION_DIRECTORY,
PGXCNodeName);