cvs: peclweb /public_html package-stats-graph.php
| From: | Greg Beaver | Date: | Wed, 18 Oct 2006 00:29:31 +0000 |
| Subject: | cvs: peclweb /public_html package-stats-graph.php | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-6503@lists.php.net to get a copy of this message | ||
cellog Wed Oct 18 00:29:31 2006 UTC
Modified files:
/peclweb/public_html package-stats-graph.php
Log:
remove potential sql injection by usage of %s instead of %d
(legacy from previous code - this is not new, unfortunately)
# thanks ilia
http://cvs.php.net/viewvc.cgi/peclweb/public_html/package-stats-graph.php?r1=1.17&r2=1.18&diff_format=u
Index: peclweb/public_html/package-stats-graph.php
diff -u peclweb/public_html/package-stats-graph.php:1.17
peclweb/public_html/package-stats-graph.php:1.18
--- peclweb/public_html/package-stats-graph.php:1.17 Tue Oct 17 22:32:09 2006
+++ peclweb/public_html/package-stats-graph.php Wed Oct 18 00:29:31 2006
@@ -15,7 +15,7 @@
+----------------------------------------------------------------------+
| Authors: Richard Heyes <richard@php.net> |
+----------------------------------------------------------------------+
- $Id: package-stats-graph.php,v 1.17 2006/10/17 22:32:09 cellog Exp $
+ $Id: package-stats-graph.php,v 1.18 2006/10/18 00:29:31 cellog Exp $
*/
/**
@@ -60,6 +60,10 @@
$releases = explode(',', $_GET['releases']);
}
+if (!isset($releases) || !is_array($releases)) {
+ exit;
+}
+
foreach ($releases as $release) {
$y_axis = array();
list($rid, $colour) = explode('_', $release);
@@ -70,14 +74,14 @@
$sql = sprintf("SELECT YEAR(yearmonth) AS dyear, MONTH(yearmonth) AS dmonth,
SUM(downloads) AS downloads
FROM aggregated_package_stats a, releases r
- WHERE a.package_id = %s
+ WHERE a.package_id = %d
AND r.id = a.release_id
AND r.package = a.package_id
AND yearmonth > (now() - INTERVAL 1 YEAR)
%s
GROUP BY dyear, dmonth
ORDER BY dyear DESC, dmonth DESC",
- $_GET['pid'],
+ (int) $_GET['pid'],
$release_clause = $rid > 0 ? 'AND a.release_id = ' . $rid :
'');
if ($result = $dbh->query($sql)) {