Skip to content

Commit 0210c7d

Browse files
committed
check more user-supplied strings used as SQL identifier
Adds checks for the prefix and schema commandline parameters and for column names and types from the pgsql style file.
1 parent bc819b5 commit 0210c7d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/options.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "format.hpp"
1111
#include "logging.hpp"
1212
#include "options.hpp"
13+
#include "pgsql.hpp"
1314
#include "reprojection.hpp"
1415
#include "util.hpp"
1516
#include "version.hpp"
@@ -394,6 +395,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
394395
break;
395396
case 'p':
396397
prefix = optarg;
398+
check_identifier(prefix, "prefix");
397399
break;
398400
case 'd':
399401
database_options.db = optarg;
@@ -557,9 +559,11 @@ options_t::options_t(int argc, char *argv[]) : options_t()
557559
break;
558560
case 215:
559561
middle_dbschema = optarg;
562+
check_identifier(middle_dbschema, "middle-schema");
560563
break;
561564
case 216:
562565
output_dbschema = optarg;
566+
check_identifier(output_dbschema, "output-pgsql-schema");
563567
break;
564568
case 217:
565569
if (std::strcmp(optarg, "false") == 0) {

src/table.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,14 @@ void table_t::start(std::string const &conninfo, std::string const &table_space)
107107

108108
//first with the regular columns
109109
for (auto const &column : m_columns) {
110+
check_identifier(column.name, "column");
111+
check_identifier(column.type_name, "column type");
110112
sql += R"("{}" {},)"_format(column.name, column.type_name);
111113
}
112114

113115
//then with the hstore columns
114116
for (auto const &hcolumn : m_hstore_columns) {
117+
check_identifier(hcolumn, "column");
115118
sql += R"("{}" hstore,)"_format(hcolumn);
116119
}
117120

0 commit comments

Comments
 (0)