Commit ce9c76eb authored by jake%acutex.net's avatar jake%acutex.net

Users should only be able to view attachments if they can view the bug that the…

Users should only be able to view attachments if they can view the bug that the file is attached to (bug 70189) r=tara
parent d0f18b87
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
# Rights Reserved. # Rights Reserved.
# #
# Contributor(s): Terry Weissman <terry@mozilla.org> # Contributor(s): Terry Weissman <terry@mozilla.org>
# Jacob Steenhagen <jake@acutex.net>
use diagnostics; use diagnostics;
use strict; use strict;
...@@ -27,17 +28,24 @@ require "CGI.pl"; ...@@ -27,17 +28,24 @@ require "CGI.pl";
ConnectToDatabase(); ConnectToDatabase();
my @row; quietly_check_login();
if (defined $::FORM{'attach_id'}) {
SendSQL("select mimetype, thedata from attachments where attach_id =".SqlQuote($::FORM{'attach_id'})); if ($::FORM{attach_id} !~ /^[1-9][0-9]*$/) {
@row = FetchSQLData(); DisplayError("Attachment ID should be numeric.");
exit;
} }
if (!@row) {
print "Content-type: text/html\n\n"; SendSQL("select bug_id, mimetype, thedata from attachments where attach_id = $::FORM{'attach_id'}");
PutHeader("Bad ID"); my ($bug_id, $mimetype, $thedata) = FetchSQLData();
print "Please hit back and try again.\n";
if (!$bug_id) {
DisplayError("Attachment $::FORM{attach_id} does not exist.");
exit; exit;
} }
print qq{Content-type: $row[0]\n\n$row[1]};
# Make sure the user can see the bug to which this file is attached
ValidateBugID($bug_id);
print qq{Content-type: $mimetype\n\n$thedata};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment