forked from kamba4/sunders
fix: Escapes generated SQL and validates sequence number
create_camera_update_statements.php wrote OSM tag keys and values unescaped into /migrations/*.sql. Values are now escaped and node ids cast to int. The sequence number argument must be numeric and is bound as a parameter instead of being concatenated into SQL and the output path.
This commit is contained in:
parent
189105075c
commit
3b28280333
1 changed files with 37 additions and 15 deletions
|
|
@ -2,6 +2,12 @@
|
|||
|
||||
include "config.php";
|
||||
|
||||
$seqNum = $_SERVER['argv'][1] ?? '';
|
||||
if (!ctype_digit($seqNum)) {
|
||||
echo "Invalid sequence number\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$elementTypes = array();
|
||||
$count = 0;
|
||||
$countDelete = 0;
|
||||
|
|
@ -281,8 +287,10 @@ while ($data = fread($fp, 4096)) {
|
|||
}
|
||||
}
|
||||
|
||||
$sql="UPDATE sync_state SET v='" . $_SERVER['argv'][1] ."' WHERE k='sequenceNumber';";
|
||||
$mysqli->query($sql);
|
||||
$syncStmt = $mysqli->prepare("UPDATE sync_state SET v=? WHERE k='sequenceNumber'");
|
||||
$syncStmt->bind_param('s', $seqNum);
|
||||
$syncStmt->execute();
|
||||
$syncStmt->close();
|
||||
$mysqli->commit();
|
||||
|
||||
printDebug();
|
||||
|
|
|
|||
Loading…
Reference in a new issue