Skip to content

Commit c1b048f

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 395d565 commit c1b048f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/bin/pg_dump/pg_dumpall.c

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

5555
static int runPgDump(const char *dbname);
5656
static void buildShSecLabels(PGconn *conn, const char *catalog_name,
@@ -213,7 +213,7 @@ main(int argc, char *argv[])
213213
case 'f':
214214
filename = pg_strdup(optarg);
215215
appendPQExpBuffer(pgdumpopts, " -f ");
216-
doShellQuoting(pgdumpopts, filename);
216+
appendShellString(pgdumpopts, filename);
217217
break;
218218

219219
case 'g':
@@ -254,7 +254,7 @@ main(int argc, char *argv[])
254254

255255
case 'S':
256256
appendPQExpBuffer(pgdumpopts, " -S ");
257-
doShellQuoting(pgdumpopts, optarg);
257+
appendShellString(pgdumpopts, optarg);
258258
break;
259259

260260
case 't':
@@ -290,13 +290,13 @@ main(int argc, char *argv[])
290290

291291
case 2:
292292
appendPQExpBuffer(pgdumpopts, " --lock-wait-timeout ");
293-
doShellQuoting(pgdumpopts, optarg);
293+
appendShellString(pgdumpopts, optarg);
294294
break;
295295

296296
case 3:
297297
use_role = pg_strdup(optarg);
298298
appendPQExpBuffer(pgdumpopts, " --role ");
299-
doShellQuoting(pgdumpopts, use_role);
299+
appendShellString(pgdumpopts, use_role);
300300
break;
301301

302302
default:
@@ -1699,9 +1699,9 @@ runPgDump(const char *dbname)
16991699
* string.
17001700
*/
17011701
appendPQExpBuffer(connstrbuf, "%s dbname=", connstr);
1702-
doConnStrQuoting(connstrbuf, dbname);
1702+
appendConnStrVal(connstrbuf, dbname);
17031703

1704-
doShellQuoting(cmd, connstrbuf->data);
1704+
appendShellString(cmd, connstrbuf->data);
17051705

17061706
appendPQExpBuffer(cmd, "%s", SYSTEMQUOTE);
17071707

@@ -1983,7 +1983,7 @@ constructConnStr(const char **keywords, const char **values)
19831983
appendPQExpBufferChar(buf, ' ');
19841984
firstkeyword = false;
19851985
appendPQExpBuffer(buf, "%s=", keywords[i]);
1986-
doConnStrQuoting(buf, values[i]);
1986+
appendConnStrVal(buf, values[i]);
19871987
}
19881988

19891989
connstr = pg_strdup(buf->data);
@@ -2076,7 +2076,7 @@ dumpTimestamp(char *msg)
20762076
* string
20772077
*/
20782078
static void
2079-
doConnStrQuoting(PQExpBuffer buf, const char *str)
2079+
appendConnStrVal(PQExpBuffer buf, const char *str)
20802080
{
20812081
const char *s;
20822082
bool needquotes;
@@ -2125,7 +2125,7 @@ doConnStrQuoting(PQExpBuffer buf, const char *str)
21252125
* there eventually leads to errors here.
21262126
*/
21272127
static void
2128-
doShellQuoting(PQExpBuffer buf, const char *str)
2128+
appendShellString(PQExpBuffer buf, const char *str)
21292129
{
21302130
const char *p;
21312131

0 commit comments

Comments
 (0)