]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
runtests: abort early if runpingpongserver is given a bad server type
authorDan Fandrich <dan@coneharvesters.com>
Sat, 8 Apr 2023 22:27:39 +0000 (15:27 -0700)
committerDan Fandrich <dan@coneharvesters.com>
Tue, 11 Apr 2023 21:55:32 +0000 (14:55 -0700)
tests/servers.pm

index b16a66f31c2350f9f6f68f0b1cbe1573bae35a2d..0f63c585df9c68ed56d25229a7b18da1e55bbcb2 100644 (file)
@@ -1468,6 +1468,13 @@ sub runhttptlsserver {
 #
 sub runpingpongserver {
     my ($proto, $id, $verb, $ipv6) = @_;
+
+    # Check the requested server
+    if($proto !~ /^(?:ftp|imap|pop3|smtp)$/) {
+        print STDERR "Unsupported protocol $proto!!\n";
+        return (0,0);
+    }
+
     my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP";
     my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4;
     my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1;
@@ -1532,13 +1539,7 @@ sub runpingpongserver {
     logmsg "RUN: $srvrname server is PID $ftppid port $port\n" if($verb);
 
     # Assign the correct port variable!
-    if($proto =~ /^(?:ftp|imap|pop3|smtp)$/) {
-        $PORT{$proto . ($ipvnum == 6? '6': '')} = $port;
-    }
-    else {
-        print STDERR "Unsupported protocol $proto!!\n";
-        return (0,0);
-    }
+    $PORT{$proto . ($ipvnum == 6? '6': '')} = $port;
 
     return ($pid2, $ftppid);
 }