Skip to content

Commit

Permalink
test/recipes/80-test_cmp_http.t: Don't trust $server_port in start_mo…
Browse files Browse the repository at this point in the history
…ck_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 openssl#15557
Fixes openssl#15571

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from openssl#15580)
  • Loading branch information
levitte committed Jun 6, 2021
1 parent d00be9f commit 97cf9b0
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions test/recipes/80-test_cmp_http.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 97cf9b0

Please sign in to comment.