提交 4658177a 编写于 作者: D Daniel Gustafsson

Quote exclude items in BASE_BACKUP message

When specifying exclusion items to pg_basebackup we need to quote
them properly to avoid the risk of breaking out of the SCONST rule
in the lexer with ./pg_basebackup -E "foo'NOWAIT EXCLUDE'bar" or
something equally silly.
上级 d16226bd
......@@ -1287,6 +1287,9 @@ build_exclude_list(char **exclude_list, int num)
{
PQExpBufferData buf;
int i;
char quoted[MAXPGPATH];
int error;
size_t len;
if (num == 0)
return "";
......@@ -1295,7 +1298,15 @@ build_exclude_list(char **exclude_list, int num)
for (i = 0; i < num; i++)
{
appendPQExpBuffer(&buf, "EXCLUDE '%s'", exclude_list[i]);
error = 1;
len = PQescapeStringConn(conn, quoted, exclude_list[i], MAXPGPATH, &error);
if (len == 0 || error != 0)
{
fprintf(stderr, _("%s: could not process exclude \"%s\": %s\n"),
progname, exclude_list[i], PQerrorMessage(conn));
disconnect_and_exit(1);
}
appendPQExpBuffer(&buf, "EXCLUDE '%s'", quoted);
}
if (PQExpBufferDataBroken(buf))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册