Module: wine
Branch: master
Commit: cae161389b688b414b1c187fd7d3d61595544021
URL: https://source.winehq.org/git/wine.git/?a=commit;h=cae161389b688b414b1c187f…
Author: Hans Leidekker <hans(a)codeweavers.com>
Date: Fri Jun 11 14:37:25 2021 +0200
secur32: Translate errors from push/pull callbacks.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51192
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/secur32/schannel.c | 12 +++++-------
dlls/secur32/schannel_gnutls.c | 19 +++++++++++++++----
dlls/secur32/schannel_macosx.c | 4 ++--
3 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c
index 50a1c848c0e..9c7e98b32a4 100644
--- a/dlls/secur32/schannel.c
+++ b/dlls/secur32/schannel.c
@@ -759,9 +759,8 @@ static char * CDECL schan_get_buffer(const struct schan_transport *t, struct sch
* *buff_len > 0 indicates that some data was read. May be less than
* what was requested, in which case the caller should call again if/
* when they want more.
- * EAGAIN when no data could be read without blocking
+ * -1 when no data could be read without blocking
* another errno-style error value on failure
- *
*/
static int CDECL schan_pull(struct schan_transport *t, void *buff, size_t *buff_len)
{
@@ -774,7 +773,7 @@ static int CDECL schan_pull(struct schan_transport *t, void *buff, size_t *buff_
b = schan_get_buffer(t, &t->in, &local_len);
if (!b)
- return EAGAIN;
+ return -1;
memcpy(buff, b, local_len);
t->in.offset += local_len;
@@ -797,10 +796,9 @@ static int CDECL schan_pull(struct schan_transport *t, void *buff, size_t *buff_
* 0 on success
* *buff_len will be > 0 indicating how much data was written. May be less
* than what was requested, in which case the caller should call again
- if/when they want to write more.
- * EAGAIN when no data could be written without blocking
+ * if/when they want to write more.
+ * -1 when no data could be written without blocking
* another errno-style error value on failure
- *
*/
static int CDECL schan_push(struct schan_transport *t, const void *buff, size_t *buff_len)
{
@@ -813,7 +811,7 @@ static int CDECL schan_push(struct schan_transport *t, const void *buff, size_t
b = schan_get_buffer(t, &t->out, &local_len);
if (!b)
- return EAGAIN;
+ return -1;
memcpy(b, buff, local_len);
t->out.offset += local_len;
diff --git a/dlls/secur32/schannel_gnutls.c b/dlls/secur32/schannel_gnutls.c
index 76ab230137d..93868d10b3b 100644
--- a/dlls/secur32/schannel_gnutls.c
+++ b/dlls/secur32/schannel_gnutls.c
@@ -28,6 +28,7 @@
#include <stdarg.h>
#include <stdio.h>
+#include <errno.h>
#ifdef SONAME_LIBGNUTLS
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
@@ -204,9 +205,14 @@ static ssize_t pull_adapter(gnutls_transport_ptr_t transport, void *buff, size_t
gnutls_session_t s = (gnutls_session_t)callbacks->get_session_for_transport(t);
int ret = callbacks->pull(transport, buff, &buff_len);
- if (ret)
+ if (ret == -1)
{
- pgnutls_transport_set_errno(s, ret);
+ pgnutls_transport_set_errno(s, EAGAIN);
+ return -1;
+ }
+ if (ret < 0)
+ {
+ FIXME("unhandled error from pull callback %d\n", ret);
return -1;
}
@@ -219,9 +225,14 @@ static ssize_t push_adapter(gnutls_transport_ptr_t transport, const void *buff,
gnutls_session_t s = (gnutls_session_t)callbacks->get_session_for_transport(t);
int ret = callbacks->push(transport, buff, &buff_len);
- if (ret)
+ if (ret == -1)
+ {
+ pgnutls_transport_set_errno(s, EAGAIN);
+ return -1;
+ }
+ if (ret < 0)
{
- pgnutls_transport_set_errno(s, ret);
+ FIXME("unhandled error from push callback %d\n", ret);
return -1;
}
diff --git a/dlls/secur32/schannel_macosx.c b/dlls/secur32/schannel_macosx.c
index daf9d835835..f4f84557dfe 100644
--- a/dlls/secur32/schannel_macosx.c
+++ b/dlls/secur32/schannel_macosx.c
@@ -672,7 +672,7 @@ static OSStatus pull_adapter(SSLConnectionRef transport, void *buff, SIZE_T *buf
ret = noErr;
}
}
- else if (status == EAGAIN)
+ else if (status == -1)
{
TRACE("Would block before being able to pull anything\n");
ret = errSSLWouldBlock;
@@ -723,7 +723,7 @@ static OSStatus push_adapter(SSLConnectionRef transport, const void *buff, SIZE_
TRACE("Pushed %lu bytes\n", *buff_len);
ret = noErr;
}
- else if (status == EAGAIN)
+ else if (status == -1)
{
TRACE("Would block before being able to push anything\n");
ret = errSSLWouldBlock;