summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Vondra2017-07-29 16:54:59 +0000
committerTomas Vondra2017-07-31 01:20:14 +0000
commita1b98e2c82f45fa53c949ce93a9477da2277308e (patch)
tree08b4562390a9ae166a473033e994e458473ef777
parent09765ec199f231ace0e1b4f4700c2b02d6bf3d3b (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 b7fdf77a72..b63c5ffd04 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -401,8 +401,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);