Protect user against bad regexps
authorJamie Cameron <jcameron@webmin.com>
Thu, 13 Nov 2008 18:51:48 +0000 (18:51 +0000)
committerJamie Cameron <jcameron@webmin.com>
Thu, 13 Nov 2008 18:51:48 +0000 (18:51 +0000)
status/http-monitor.pl
status/proc-monitor.pl

index c688064..28f61ef 100644 (file)
@@ -42,9 +42,12 @@ eval {
                while(defined($buf = &read_http_connection($con))) {
                        $data .= $buf;
                        }
-               if ($data !~ /$re/i) {
-                       $up = 0;
-                       }
+               eval {
+                       # Check for regexp match
+                       if ($data !~ /$re/i) {
+                               $up = 0;
+                               }
+                       };
                }
 
        &close_http_connection($con);
index 91dc734..9907b1c 100644 (file)
@@ -7,7 +7,7 @@ local (@found, $count);
 return { 'up' => -1 } if (!&foreign_check("proc"));
 &foreign_require("proc", "proc-lib.pl");
 foreach $p (&foreign_call("proc", "list_processes")) {
-       if ($p->{'args'} =~ /$_[0]->{'cmd'}/i &&
+       if (eval { $p->{'args'} =~ /$_[0]->{'cmd'}/i } &&
            (!$_[0]->{'asuser'} || $_[0]->{'asuser'} eq $p->{'user'})) {
                push(@found, $p->{'pid'});
                $count++;