Fix potential (safe) SQL-injection

This commit is contained in:
Alexey Milovidov 2021-01-16 11:15:43 +03:00
parent 31593e2000
commit 45380d45c8

View File

@ -99,6 +99,13 @@ std::unordered_set<std::string> DatabasePostgreSQL::fetchTablesList() const
bool DatabasePostgreSQL::checkPostgresTable(const String & table_name) const bool DatabasePostgreSQL::checkPostgresTable(const String & table_name) const
{ {
if (table_name.find('\'') != std::string::npos
|| table_name.find('\\') != std::string::npos)
{
throw Exception(ErrorCodes::BAD_ARGUMENTS,
"PostgreSQL table name cannot contain single quote or backslash characters, passed {}", table_name);
}
pqxx::nontransaction tx(*connection->conn()); pqxx::nontransaction tx(*connection->conn());
try try