Skip to content

Commit f1d0b09

Browse files
committed
Promote pg_dumpall shell/connstr quoting functions to src/fe_utils.
Rename these newly-extern functions with terms more typical of their new neighbors. No functional changes; a subsequent commit will use them in more places. Back-patch to 9.1 (all supported versions). Back branches lack src/fe_utils, so instead rename the functions in place; the subsequent commit will copy them into the other programs using them. Security: CVE-2016-5424
1 parent a19edcd commit f1d0b09

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/bin/pg_dump/pg_dumpall.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ static void makeAlterConfigCommand(PGconn *conn, const char *arrayitem,
4848
const char *name2);
4949
static void dumpDatabases(PGconn *conn);
5050
static void dumpTimestamp(char *msg);
51-
static void doShellQuoting(PQExpBuffer buf, const char *str);
52-
static void doConnStrQuoting(PQExpBuffer buf, const char *str);
51+
static void appendShellString(PQExpBuffer buf, const char *str);
52+
static void appendConnStrVal(PQExpBuffer buf, const char *str);
5353

5454
static int runPgDump(const char *dbname);
5555
static void buildShSecLabels(PGconn *conn, const char *catalog_name,
@@ -203,7 +203,7 @@ main(int argc, char *argv[])
203203
case 'f':
204204
filename = optarg;
205205
appendPQExpBuffer(pgdumpopts, " -f ");
206-
doShellQuoting(pgdumpopts, filename);
206+
appendShellString(pgdumpopts, filename);
207207
break;
208208

209209
case 'g':
@@ -213,7 +213,7 @@ main(int argc, char *argv[])
213213
case 'h':
214214
pghost = optarg;
215215
appendPQExpBuffer(pgdumpopts, " -h ");
216-
doShellQuoting(pgdumpopts, pghost);
216+
appendShellString(pgdumpopts, pghost);
217217
break;
218218

219219
case 'i':
@@ -235,7 +235,7 @@ main(int argc, char *argv[])
235235
case 'p':
236236
pgport = optarg;
237237
appendPQExpBuffer(pgdumpopts, " -p ");
238-
doShellQuoting(pgdumpopts, pgport);
238+
appendShellString(pgdumpopts, pgport);
239239
break;
240240

241241
case 'r':
@@ -248,7 +248,7 @@ main(int argc, char *argv[])
248248

249249
case 'S':
250250
appendPQExpBuffer(pgdumpopts, " -S ");
251-
doShellQuoting(pgdumpopts, optarg);
251+
appendShellString(pgdumpopts, optarg);
252252
break;
253253

254254
case 't':
@@ -258,7 +258,7 @@ main(int argc, char *argv[])
258258
case 'U':
259259
pguser = optarg;
260260
appendPQExpBuffer(pgdumpopts, " -U ");
261-
doShellQuoting(pgdumpopts, pguser);
261+
appendShellString(pgdumpopts, pguser);
262262
break;
263263

264264
case 'v':
@@ -286,13 +286,13 @@ main(int argc, char *argv[])
286286

287287
case 2:
288288
appendPQExpBuffer(pgdumpopts, " --lock-wait-timeout ");
289-
doShellQuoting(pgdumpopts, optarg);
289+
appendShellString(pgdumpopts, optarg);
290290
break;
291291

292292
case 3:
293293
use_role = optarg;
294294
appendPQExpBuffer(pgdumpopts, " --role ");
295-
doShellQuoting(pgdumpopts, use_role);
295+
appendShellString(pgdumpopts, use_role);
296296
break;
297297

298298
default:
@@ -1679,9 +1679,9 @@ runPgDump(const char *dbname)
16791679
* incorrectly treat it as a connection string.
16801680
*/
16811681
appendPQExpBufferStr(connstrbuf, "dbname=");
1682-
doConnStrQuoting(connstrbuf, dbname);
1682+
appendConnStrVal(connstrbuf, dbname);
16831683

1684-
doShellQuoting(cmd, connstrbuf->data);
1684+
appendShellString(cmd, connstrbuf->data);
16851685

16861686
appendPQExpBuffer(cmd, "%s", SYSTEMQUOTE);
16871687

@@ -1940,7 +1940,7 @@ dumpTimestamp(char *msg)
19401940
* string
19411941
*/
19421942
static void
1943-
doConnStrQuoting(PQExpBuffer buf, const char *str)
1943+
appendConnStrVal(PQExpBuffer buf, const char *str)
19441944
{
19451945
const char *s;
19461946
bool needquotes;
@@ -1989,7 +1989,7 @@ doConnStrQuoting(PQExpBuffer buf, const char *str)
19891989
* there eventually leads to errors here.
19901990
*/
19911991
static void
1992-
doShellQuoting(PQExpBuffer buf, const char *str)
1992+
appendShellString(PQExpBuffer buf, const char *str)
19931993
{
19941994
const char *p;
19951995

0 commit comments

Comments
 (0)