mirror of
https://github.com/openssl/openssl.git
synced 2024-11-30 13:34:44 +08:00
test/recipes/80-test_cmp_http.t: Don't trust $server_port in start_mock_server()
Even if $server_port isn't touched, it's still a number coming from configuration. It's therefore not trustable as an indicator that the ACCEPT line delivered a port number or an error indication. $accept_msg is used instead to capture the port if there is one, and be a better indicator of error. Fixes #15557 Fixes #15571 Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/15580)
This commit is contained in:
parent
d00be9f387
commit
97cf9b05fa
@ -276,19 +276,30 @@ sub start_mock_server {
|
||||
my $pid = open($server_fh, "$cmd|") or die "Trying to $cmd";
|
||||
print "Pid is: $pid\n";
|
||||
if ($server_port == 0) {
|
||||
# Clear it first
|
||||
$server_port = undef;
|
||||
|
||||
# Find out the actual server port
|
||||
while (<$server_fh>) {
|
||||
print;
|
||||
s/\R$//; # Better chomp
|
||||
next unless (/^ACCEPT/);
|
||||
$server_port = $server_tls = $kur_port = $pbm_port = $1
|
||||
if m/^ACCEPT\s.*?:(\d+)$/;
|
||||
|
||||
# $1 may be undefined, which is OK to assign to $server_port,
|
||||
# as that gets detected further down.
|
||||
/^ACCEPT\s.*:(\d+)$/;
|
||||
$server_port = $1;
|
||||
|
||||
last;
|
||||
}
|
||||
|
||||
unless (defined $server_port) {
|
||||
stop_mock_server($pid);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return $pid if $server_port =~ m/^(\d+)$/;
|
||||
stop_mock_server($pid);
|
||||
return 0;
|
||||
$server_tls = $kur_port = $pbm_port = $server_port;
|
||||
return $pid;
|
||||
}
|
||||
|
||||
sub stop_mock_server {
|
||||
|
Loading…
Reference in New Issue
Block a user