From 2b494771fdaa05eeea2c9789b36e455e46468d41 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 7 Jan 2010 13:58:49 -0800 Subject: [PATCH] stream-ssl: Fix ssl_recv() and ssl_send() return value semantics. These functions' return value semantics did not match those documented in stream-provider.h. --- lib/stream-ssl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c index 436dc7b2..6839341c 100644 --- a/lib/stream-ssl.c +++ b/lib/stream-ssl.c @@ -549,7 +549,8 @@ ssl_recv(struct stream *stream, void *buffer, size_t n) if (error == SSL_ERROR_ZERO_RETURN) { return 0; } else { - return interpret_ssl_error("SSL_read", ret, error, &sslv->rx_want); + return -interpret_ssl_error("SSL_read", ret, error, + &sslv->rx_want); } } } @@ -597,7 +598,7 @@ ssl_send(struct stream *stream, const void *buffer, size_t n) struct ssl_stream *sslv = ssl_stream_cast(stream); if (sslv->txbuf) { - return EAGAIN; + return -EAGAIN; } else { int error; @@ -606,13 +607,13 @@ ssl_send(struct stream *stream, const void *buffer, size_t n) switch (error) { case 0: ssl_clear_txbuf(sslv); - return 0; + return n; case EAGAIN: leak_checker_claim(buffer); - return 0; + return n; default: sslv->txbuf = NULL; - return error; + return -error; } } } -- 2.30.2