From 06b1a12b3b5b75a5626b2dff8c63d95dc5bc5f63 Mon Sep 17 00:00:00 2001 From: Frank Breedijk Date: Mon, 25 Jul 2016 11:45:24 +0200 Subject: [PATCH] Fixed startssl protocol errors. count_lines function always returns at least 1 For now I fixed this with a wc -l command, I hope @drwetter can fix the count_lines function for me --- t/06_client_sims_starttls.t | 6 +++--- testssl.sh | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/t/06_client_sims_starttls.t b/t/06_client_sims_starttls.t index dfb7150..c50c568 100755 --- a/t/06_client_sims_starttls.t +++ b/t/06_client_sims_starttls.t @@ -17,9 +17,9 @@ my $socketout = `./testssl.sh -c -t smtp --jsonfile tmp.json --color 0 smtp-rela my $socket = json('tmp.json'); like($socketout, qr/Running client simulations via sockets/, "Tests ran via sockets"); $tests++; -my $i = 0; -foreach my $o ( @$openssl ) { - my $s = $$socket[$i]; +my $i = 1; # Need to start counting at 1 +foreach my $s ( @$socket ) { + my $o = $$openssl[$i]; if ( $o->{id} =~ /^client_/ ) { pass("Comparing $o->{id}"); $tests++; cmp_ok($o->{id}, "eq", $s->{id}, "Id's match"); $tests++; diff --git a/testssl.sh b/testssl.sh index e1c5b19..1a1b6ca 100755 --- a/testssl.sh +++ b/testssl.sh @@ -2042,12 +2042,12 @@ run_client_simulation() { outln if "$using_sockets"; then - pr_headlineln " Running client simulations via sockets " + pr_headlineln " Running client simulations via sockets (experimental) " else - pr_headlineln " Running client simulations (experimental) " + pr_headlineln " Running client simulations via openssl (experimental) " outln pr_warningln " Depending on your openssl client and the server side this may yield to false values" - fileout "client_simulation" "WARNING" "Depending on your openssl client and the server side this may yield to false values" + fileout "client_simulation_openssl" "WARNING" "Running simulations via openssl, depending on your openssl client and the server side this may yield to false values" fi outln @@ -2055,7 +2055,9 @@ run_client_simulation() { for name in "${short[@]}"; do # Make sure we run client simulations for those clients that support it if $do_all_simulations || ${current[i]} ; then - if $do_all_simulations || [[ $(count_lines "$(echo "${service[i]}" | grep "$client_service")") -eq 1 || "${service[i]}" == "ANY" ]]; then + # if $do_all_simulations || [[ $(count_lines "$(echo "${service[i]}" | grep "$client_service")") -eq 1 || "${service[i]}" == "ANY" ]]; then + # I know @drwetter hates wc -l, but in this case wc -l and count_lines give different results + if $do_all_simulations || [[ $(echo "${service[i]}" | grep "$client_service" |wc -l ) -eq 1 || "${service[i]}" == "ANY" ]]; then #FIXME: printf formatting would look better, especially if we want a wide option here out " ${names[i]} " if $using_sockets && [[ -n "${handshakebytes[i]}" ]]; then