LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0001-Fix-a-TLSProxy-race-condition.patch of Package openssl-1_1_0 (Project home:jayvdb:zypper)

From b72668a0d3586ee2560f0536c43e18991a4cfc6f Mon Sep 17 00:00:00 2001
From: Matt Caswell <matt@openssl.org>
Date: Fri, 26 May 2017 13:06:08 +0100
Subject: [PATCH] Fix a Proxy race condition

Issue #3562 describes a problem where a race condition can occur in the
Proxy such that a test "ok" line can appear in the middle of other text
causing the test harness to miss it. The issue is that we do not wait for
the client process to finish after the test is complete, so that process may
continue to write data to stdout/stderr at the same time that the test
harness does.

This commit fixes TLSProxy so that we always wait for the client process to
finish before continuing.

Fixes #3562

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3567)
---
 util/TLSProxy/Proxy.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Index: openssl-1.1.0f/util/TLSProxy/Proxy.pm
===================================================================
--- openssl-1.1.0f.orig/util/TLSProxy/Proxy.pm	2017-07-18 13:48:24.282938212 +0200
+++ openssl-1.1.0f/util/TLSProxy/Proxy.pm	2017-07-18 13:49:22.999903552 +0200
@@ -42,6 +42,7 @@ sub new
         clientflags => "",
         serverconnects => 1,
         serverpid => 0,
+        clientpid => 0,
         reneg => 0,
 
         #Public read
@@ -104,6 +105,7 @@ sub clearClient
     $self->{record_list} = [];
     $self->{message_list} = [];
     $self->{clientflags} = "";
+    $self->{clientpid} = 0;
 
     TLSProxy::Message->clear();
     TLSProxy::Record->clear();
@@ -225,6 +227,7 @@ sub clientstart
             }
             exec($execcmd);
         }
+        $self->clientpid($pid);
     }
 
     # Wait for incoming connection from client
@@ -315,6 +318,10 @@ sub clientstart
         waitpid( $self->serverpid, 0);
         die "exit code $? from server process\n" if $? != 0;
     }
+    die "clientpid is zero\n" if $self->clientpid == 0;
+    print "Waiting for client process to close: ".$self->clientpid."\n";
+    waitpid($self->clientpid, 0);
+
     return 1;
 }
 
@@ -508,6 +515,14 @@ sub serverpid
     }
     return $self->{serverpid};
 }
+sub clientpid
+{
+    my $self = shift;
+    if (@_) {
+        $self->{clientpid} = shift;
+    }
+    return $self->{clientpid};
+}
 
 sub fill_known_data
 {