mbedtls/programs/ssl
Manuel Pégourié-Gonnard e56c77eeb2 Fix race condition in error printing in ssl_server2.c
The race goes this way:
1. ssl_recv() succeeds (ie no signal received yet)
2. processing the message leads to aborting handshake with ret != 0
3. reset ret if we were signaled
4. print error if ret is still non-zero
5. go back to net_accept() which can be interrupted by a signal
We print the error message only if the signal is received between steps 3 and
5, not when it arrives between steps 1 and 3.

This can cause failures in ssl-opt.sh where we check for the presence of "Last
error was..." in the server's output: if we perform step 2, the client will be
notified and exit, then ssl-opt.sh will send SIGTERM to the server, but if it
didn't get a chance to run and pass step 3 in the meantime, we're in trouble.

The purpose of step 3 was to avoid spurious "Last error" messages in the
output so that ssl-opt.sh can check for a successful run by the absence of
that message. However, it is enough to suppress that message when the last
error we get is the one we expect from being interrupted by a signal - doing
more could hide real errors.

Also, improve the messages printed when interrupted to make it easier to
distinguish the two cases - this could be used in a testing script wanted to
check that the server doesn't see the client as disconnecting unexpectedly.
2018-01-25 11:43:36 +01:00
..
CMakeLists.txt Fix whitespace in CMakeLists.txt 2015-06-25 10:59:57 +02:00
dtls_client.c Fix examples that failed to compile without PEM 2017-02-02 17:08:46 +00:00
dtls_server.c Change main license to Apache 2.0 2015-09-04 14:21:07 +02:00
mini_client.c Change main license to Apache 2.0 2015-09-04 14:21:07 +02:00
ssl_client1.c Fix default hostname for verification used in ssl_client1 2017-02-28 23:33:28 +00:00
ssl_client2.c Allow requests of size larger than 16384 in ssl_client2 2017-10-19 15:44:37 +01:00
ssl_fork_server.c Improves and makes pretty the ssl_fork_server output 2016-04-28 23:57:42 +01:00
ssl_mail_client.c Fix examples that failed to compile without PEM 2017-02-02 17:08:46 +00:00
ssl_pthread_server.c Change main license to Apache 2.0 2015-09-04 14:21:07 +02:00
ssl_server2.c Fix race condition in error printing in ssl_server2.c 2018-01-25 11:43:36 +01:00
ssl_server.c Change main license to Apache 2.0 2015-09-04 14:21:07 +02:00