1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-27 23:21:58 +03:00

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
This commit is contained in:
Noah Misch
2016-08-08 10:07:46 -04:00
parent a19edcd240
commit f1d0b09cf1

View File

@ -48,8 +48,8 @@ static void makeAlterConfigCommand(PGconn *conn, const char *arrayitem,
const char *name2); const char *name2);
static void dumpDatabases(PGconn *conn); static void dumpDatabases(PGconn *conn);
static void dumpTimestamp(char *msg); static void dumpTimestamp(char *msg);
static void doShellQuoting(PQExpBuffer buf, const char *str); static void appendShellString(PQExpBuffer buf, const char *str);
static void doConnStrQuoting(PQExpBuffer buf, const char *str); static void appendConnStrVal(PQExpBuffer buf, const char *str);
static int runPgDump(const char *dbname); static int runPgDump(const char *dbname);
static void buildShSecLabels(PGconn *conn, const char *catalog_name, static void buildShSecLabels(PGconn *conn, const char *catalog_name,
@ -203,7 +203,7 @@ main(int argc, char *argv[])
case 'f': case 'f':
filename = optarg; filename = optarg;
appendPQExpBuffer(pgdumpopts, " -f "); appendPQExpBuffer(pgdumpopts, " -f ");
doShellQuoting(pgdumpopts, filename); appendShellString(pgdumpopts, filename);
break; break;
case 'g': case 'g':
@ -213,7 +213,7 @@ main(int argc, char *argv[])
case 'h': case 'h':
pghost = optarg; pghost = optarg;
appendPQExpBuffer(pgdumpopts, " -h "); appendPQExpBuffer(pgdumpopts, " -h ");
doShellQuoting(pgdumpopts, pghost); appendShellString(pgdumpopts, pghost);
break; break;
case 'i': case 'i':
@ -235,7 +235,7 @@ main(int argc, char *argv[])
case 'p': case 'p':
pgport = optarg; pgport = optarg;
appendPQExpBuffer(pgdumpopts, " -p "); appendPQExpBuffer(pgdumpopts, " -p ");
doShellQuoting(pgdumpopts, pgport); appendShellString(pgdumpopts, pgport);
break; break;
case 'r': case 'r':
@ -248,7 +248,7 @@ main(int argc, char *argv[])
case 'S': case 'S':
appendPQExpBuffer(pgdumpopts, " -S "); appendPQExpBuffer(pgdumpopts, " -S ");
doShellQuoting(pgdumpopts, optarg); appendShellString(pgdumpopts, optarg);
break; break;
case 't': case 't':
@ -258,7 +258,7 @@ main(int argc, char *argv[])
case 'U': case 'U':
pguser = optarg; pguser = optarg;
appendPQExpBuffer(pgdumpopts, " -U "); appendPQExpBuffer(pgdumpopts, " -U ");
doShellQuoting(pgdumpopts, pguser); appendShellString(pgdumpopts, pguser);
break; break;
case 'v': case 'v':
@ -286,13 +286,13 @@ main(int argc, char *argv[])
case 2: case 2:
appendPQExpBuffer(pgdumpopts, " --lock-wait-timeout "); appendPQExpBuffer(pgdumpopts, " --lock-wait-timeout ");
doShellQuoting(pgdumpopts, optarg); appendShellString(pgdumpopts, optarg);
break; break;
case 3: case 3:
use_role = optarg; use_role = optarg;
appendPQExpBuffer(pgdumpopts, " --role "); appendPQExpBuffer(pgdumpopts, " --role ");
doShellQuoting(pgdumpopts, use_role); appendShellString(pgdumpopts, use_role);
break; break;
default: default:
@ -1679,9 +1679,9 @@ runPgDump(const char *dbname)
* incorrectly treat it as a connection string. * incorrectly treat it as a connection string.
*/ */
appendPQExpBufferStr(connstrbuf, "dbname="); appendPQExpBufferStr(connstrbuf, "dbname=");
doConnStrQuoting(connstrbuf, dbname); appendConnStrVal(connstrbuf, dbname);
doShellQuoting(cmd, connstrbuf->data); appendShellString(cmd, connstrbuf->data);
appendPQExpBuffer(cmd, "%s", SYSTEMQUOTE); appendPQExpBuffer(cmd, "%s", SYSTEMQUOTE);
@ -1940,7 +1940,7 @@ dumpTimestamp(char *msg)
* string * string
*/ */
static void static void
doConnStrQuoting(PQExpBuffer buf, const char *str) appendConnStrVal(PQExpBuffer buf, const char *str)
{ {
const char *s; const char *s;
bool needquotes; bool needquotes;
@ -1989,7 +1989,7 @@ doConnStrQuoting(PQExpBuffer buf, const char *str)
* there eventually leads to errors here. * there eventually leads to errors here.
*/ */
static void static void
doShellQuoting(PQExpBuffer buf, const char *str) appendShellString(PQExpBuffer buf, const char *str)
{ {
const char *p; const char *p;