Skip to content

Commit

Permalink
DatabaseContext::Private::attachExtraDatabases(): fix false-positive …
Browse files Browse the repository at this point in the history
…CodeQL cpp/sql-injection
  • Loading branch information
rouault committed Jan 10, 2024
1 parent 011584c commit 4af728b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/iso19111/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,18 +1282,15 @@ void DatabaseContext::Private::attachExtraDatabases(
sqlite_handle, true, nLayoutVersionMajor, nLayoutVersionMinor);
l_handle = sqlite_handle_;

run("ATTACH DATABASE '" + replaceAll(databasePath_, "'", "''") +
"' AS db_0");
run("ATTACH DATABASE ? AS db_0", {databasePath_});
detach_ = true;
int count = 1;
for (const auto &otherDbPath : auxiliaryDatabasePaths) {
const auto attachedDbName("db_" + toString(static_cast<int>(count)));
std::string sql = "ATTACH DATABASE '";
sql += replaceAll(otherDbPath, "'", "''");
sql += "' AS ";
std::string sql = "ATTACH DATABASE ? AS ";
sql += attachedDbName;
count++;
run(sql);
run(sql, {otherDbPath});

l_handle->checkDatabaseLayout(databasePath_, otherDbPath,
attachedDbName + '.');
Expand Down

0 comments on commit 4af728b

Please sign in to comment.