]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 544990: Allow directory names in page.cgi ids
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Mon, 8 Feb 2010 23:51:51 +0000 (15:51 -0800)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Mon, 8 Feb 2010 23:51:51 +0000 (15:51 -0800)
r=LpSolit, a=mkanat

page.cgi

index cd6cb611ec5747ec6bf0d17d83aeea68e7c61d59..9326229a5d074fa70d25d777e04c5d4fb3fa55b0 100755 (executable)
--- a/page.cgi
+++ b/page.cgi
@@ -66,9 +66,9 @@ my $template = Bugzilla->template;
 
 my $id = $cgi->param('id');
 if ($id) {
-    # Remove all dodgy chars, and split into name and ctype.
-    $id =~ s/[^\w\-\.]//g;
-    $id =~ /(.*)\.(.*)/;
+    # Split into name and ctype, but be careful not to allow directory
+    # traversal.
+    $id =~ /^([\w\-\/]+)\.(\w+)$/;
     if (!$2) {
         # if this regexp fails to match completely, something bad came in
         ThrowCodeError("bad_page_cgi_id", { "page_id" => $id });