r91369 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91368‎ | r91369 | r91370 >
Date:09:47, 3 July 2011
Author:yuvipanda
Status:ok
Tags:
Comment:
Fixed an SQL Injection hole
Modified paths:
  • /trunk/extensions/GPoC/models/Rating.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GPoC/models/Rating.php
@@ -52,7 +52,6 @@
5353 $this->saveAll();
5454 }
5555
56 - // Note: Huge sql injection vector ahead. FIXME
5756 private function updateAggregateStats( $is_new_rating ) {
5857 if(! $is_new_rating && empty($this->old_importance) && empty($this->old_quality) ) {
5958 return;
@@ -61,8 +60,10 @@
6261 // Rating has just been detected.
6362 // So we can ignore $old_importance and $old_quality
6463 $importance_column = Rating::getImportanceColumn( $this->importance );
 64+ $project = $dbw->addQuotes($this->project);
 65+ $quality = $dbw->addQuotes($this->quality);
6566 $query = "INSERT INTO project_stats (ps_project, ps_quality, $importance_column) ";
66 - $query .= "VALUES ('$this->project', '$this->quality', 1) ";
 67+ $query .= "VALUES ($project, $quality, 1) ";
6768 $query .= "ON DUPLICATE KEY ";
6869 $query .= "UPDATE $importance_column = $importance_column + 1 ";
6970 if(! $is_new_rating && ! empty( $this->old_importance ) ) {
@@ -75,6 +76,7 @@
7677 if(! isset($old_importance_column) ) {
7778 $old_importance_column = $importance_column;
7879 }
 80+
7981 $query = "UPDATE project_stats SET $old_importance_column = $old_importance_column - 1 ";
8082 $query .= "WHERE ps_project = '$this->project' and ps_quality = '$this->old_quality';";
8183 $dbw->query($query);

Status & tagging log