From 80c7d1cee922540f5012949387961b414759d210 Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Wed, 13 Apr 2022 11:10:13 +0200 Subject: [PATCH 1/5] Ensure file and database names are quoted --- contrib/oid2name/oid2name.c | 2 +- src/backend/access/transam/xlog.c | 6 +++--- src/bin/pg_waldump/pg_waldump.c | 4 ++-- src/fe_utils/connect_utils.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/oid2name/oid2name.c b/contrib/oid2name/oid2name.c index a62a5eedb1..b64dcc264d 100644 --- a/contrib/oid2name/oid2name.c +++ b/contrib/oid2name/oid2name.c @@ -329,7 +329,7 @@ sql_conn(struct options *my_opts) conn = PQconnectdbParams(keywords, values, true); if (!conn) - pg_fatal("could not connect to database %s", + pg_fatal("could not connect to database \"%s\"", my_opts->dbname); if (PQstatus(conn) == CONNECTION_BAD && diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5eabd32cf6..e1ee5794bb 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -2221,7 +2221,7 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible) errno = save_errno; ereport(PANIC, (errcode_for_file_access(), - errmsg("could not write to log file %s " + errmsg("could not write to log file \"%s\" " "at offset %u, length %zu: %m", xlogfname, startoffset, nleft))); } @@ -3572,7 +3572,7 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr lastredoptr, XLogRecPtr endptr, */ XLogFileName(lastoff, 0, segno, wal_segment_size); - elog(DEBUG2, "attempting to remove WAL segments older than log file %s", + elog(DEBUG2, "attempting to remove WAL segments older than log file \"%s\"", lastoff); xldir = AllocateDir(XLOGDIR); @@ -3649,7 +3649,7 @@ RemoveNonParentXlogFiles(XLogRecPtr switchpoint, TimeLineID newTLI) */ XLogFileName(switchseg, newTLI, switchLogSegNo, wal_segment_size); - elog(DEBUG2, "attempting to remove WAL segments newer than log file %s", + elog(DEBUG2, "attempting to remove WAL segments newer than log file \"%s\"", switchseg); xldir = AllocateDir(XLOGDIR); diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index 4f265ef546..3944f7a678 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -375,11 +375,11 @@ WALDumpReadPage(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen, if (errinfo.wre_errno != 0) { errno = errinfo.wre_errno; - pg_fatal("could not read from file %s, offset %d: %m", + pg_fatal("could not read from file \"%s\", offset %d: %m", fname, errinfo.wre_off); } else - pg_fatal("could not read from file %s, offset %d: read %d of %d", + pg_fatal("could not read from file \"%s\", offset %d: read %d of %d", fname, errinfo.wre_off, errinfo.wre_read, errinfo.wre_req); } diff --git a/src/fe_utils/connect_utils.c b/src/fe_utils/connect_utils.c index f2e583f9fa..0f7d44bfe6 100644 --- a/src/fe_utils/connect_utils.c +++ b/src/fe_utils/connect_utils.c @@ -88,7 +88,7 @@ connectDatabase(const ConnParams *cparams, const char *progname, conn = PQconnectdbParams(keywords, values, true); if (!conn) - pg_fatal("could not connect to database %s: out of memory", + pg_fatal("could not connect to database \"%s\": out of memory", cparams->dbname); /* -- 2.32.0 (Apple Git-132)