web: fix SQL injection vulnerability in remote job submission

Also cast ID to int in lookup_id.
This isn't a vulnerability AFAIK, but doesn't hurt to be safe
This commit is contained in:
David Anderson 2014-11-21 15:37:40 -08:00
parent cad6475aaa
commit 6b9205b3a1
3 changed files with 3 additions and 0 deletions

View File

@ -139,6 +139,7 @@ class BoltCourse {
}
static function lookup_name($name) {
$db = BoltDb::get();
$name = BoincDb::escape_string($name);
return $db->lookup('bolt_course', 'BoltCourse', "short_name='$name'");
}
static function enum() {

View File

@ -107,6 +107,7 @@ class DbConn {
}
function lookup_id($id, $table, $classname) {
$id = (int)$id;
return $this->lookup($table, $classname, "id=$id");
}

View File

@ -27,6 +27,7 @@ class BoincBatch {
}
static function lookup_name($name) {
$db = BoincDb::get();
$name = BoincDb::escape_string($name);
return $db->lookup('batch', 'BoincBatch', "name='$name'");
}
static function enum($clause) {