Skip to content

Fix most memory leaks problems in t/local/36_verify.t reported by Assress Sanitize #502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions t/local/36_verify.t
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ sub test_policy_checks
isnt($ret, 1, 'connect not ok: policy checks must fail') if !$ok;
is($verify_result, Net::SSLeay::X509_V_ERR_NO_EXPLICIT_POLICY(), 'Verify result is X509_V_ERR_NO_EXPLICIT_POLICY');
}

Net::SSLeay::free($ssl); # call SSL_free()
Net::SSLeay::X509_VERIFY_PARAM_free($pm);
}

Expand Down Expand Up @@ -186,9 +186,8 @@ sub test_hostname_checks
} else {
is($peername, undef, 'X509_VERIFY_PARAM_get0_peername returns undefined');
}

Net::SSLeay::free($ssl); # call SSL_free()
Net::SSLeay::X509_VERIFY_PARAM_free($pm);
Net::SSLeay::X509_VERIFY_PARAM_free($pm2);
}
}

Expand Down Expand Up @@ -305,6 +304,7 @@ sub client {
test_hostname_checks($ctx, $cl, 1) if $task eq 'hostname_checks_ok';
test_hostname_checks($ctx, $cl, 0) if $task eq 'hostname_checks_fail';
test_wildcard_checks($ctx, $cl) if $task eq 'wildcard_checks';
Net::SSLeay::CTX_free($ctx);
last if $task eq 'finish'; # Leaves $cl alive

close($cl) || die("client close: $!");
Expand All @@ -321,6 +321,7 @@ sub client {
ok($end eq Net::SSLeay::ssl_read_all($ssl), 'Successful termination');
Net::SSLeay::free($ssl);
close($cl) || die("client final close: $!");
Net::SSLeay::CTX_free($ctx);
return;
}

Expand Down Expand Up @@ -355,7 +356,11 @@ sub run_server

Net::SSLeay::set_fd($ssl, fileno($cl));
my $ret = Net::SSLeay::accept($ssl);
next unless $ret == 1;
if ($ret != 1)
{
Net::SSLeay::free($ssl);
next;
}

# Termination request or other message from client
my $msg = Net::SSLeay::ssl_read_all($ssl);
Expand All @@ -366,7 +371,9 @@ sub run_server
Net::SSLeay::free($ssl);
close($cl) || die("server close: $!");
$server->close() || die("server listen socket close: $!");
Net::SSLeay::CTX_free($ctx);
exit (0);
}
Net::SSLeay::free($ssl);
}
}