]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1083737: Validate the smtpserver parameter
authorFrédéric Buclin <LpSolit@gmail.com>
Tue, 21 Oct 2014 10:09:31 +0000 (12:09 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Tue, 21 Oct 2014 10:09:31 +0000 (12:09 +0200)
r=dkl a=glob

Bugzilla/Config/Common.pm
Bugzilla/Config/MTA.pm

index 0e3551d13f7bced1eb8674e19572050dc3c2b1e2..b69ccb543230c97e7646ea89f3caccb6bca5302d 100644 (file)
@@ -23,7 +23,7 @@ use base qw(Exporter);
     qw(check_multi check_numeric check_regexp check_url check_group
        check_sslbase check_priority check_severity check_platform
        check_opsys check_shadowdb check_urlbase check_webdotbase
-       check_user_verify_class check_ip
+       check_user_verify_class check_ip check_smtp_server
        check_mail_delivery_method check_notification check_utf8
        check_bug_status check_smtp_auth check_theschwartz_available
        check_maxattachmentsize check_email check_smtp_ssl
@@ -325,6 +325,19 @@ sub check_notification {
     return "";
 }
 
+sub check_smtp_server {
+    my $host = shift;
+    my $port;
+
+    if ($host =~ /:/) {
+        ($host, $port) = split(/:/, $host, 2);
+        unless ($port && detaint_natural($port)) {
+            return "Invalid port. It must be an integer (typically 25, 465 or 587)";
+        }
+    }
+    return "";
+}
+
 sub check_smtp_auth {
     my $username = shift;
     if ($username and !Bugzilla->feature('smtp_auth')) {
index 8184b9f5e7c668f32c1767db2fa637ca5c413e31..e6e9505a3084d8af5f7ea74ef5f46ef5496ccf3b 100644 (file)
@@ -49,7 +49,8 @@ sub get_param_list {
   {
    name => 'smtpserver',
    type => 't',
-   default => 'localhost'
+   default => 'localhost',
+   checker => \&check_smtp_server
   },
   {
    name => 'smtp_username',