From 9920a58eb20dcf33abf231e8c9439953ace3c936 Mon Sep 17 00:00:00 2001
From: Matt Caswell <matt@openssl.org>
Date: Tue, 6 Oct 2015 13:49:16 +0100
Subject: [PATCH] Fix the error code for SSL_get_async_wait_fd()

0 is a valid file descriptor so SSL_get_async_wait_fd should instead return
-1 on error.

Reviewed-by: Rich Salz <rsalz@openssl.org>
---
 apps/s_server.c | 2 +-
 ssl/ssl_lib.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/apps/s_server.c b/apps/s_server.c
index 14dd8a69db..8645c6c203 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -2014,7 +2014,7 @@ static void wait_for_async(SSL *s)
     fd_set asyncfds;
 
     fd = SSL_get_async_wait_fd(s);
-    if (!fd)
+    if (fd < 0)
         return;
 
     width = fd + 1;
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 55b64bbcb1..936e84b120 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -934,7 +934,7 @@ int SSL_waiting_for_async(SSL *s)
 int SSL_get_async_wait_fd(SSL *s)
 {
     if (!s->job)
-        return 0;
+        return -1;
 
     return ASYNC_get_wait_fd(s->job);
 }
-- 
2.25.1