From 5ec759247a9b9e7aae310f986439d8fcf1445977 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 5 Dec 2022 11:29:38 +0100 Subject: [PATCH] openssl: return -1 on error in the BIO callbacks BIO_read and BIO_write return negative numbers on error, including retryable ones. A regression from 55807e6. Both branches should be returning -1. The APIs are patterned after POSIX read and write which, similarly, return -1 on errors, not zero, with EAGAIN treated as an error. Bug: https://github.com/curl/curl/issues/10013#issuecomment-1335308146 Reported-by: David Benjamin Closes #10021 --- lib/vtls/openssl.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index dd7201ac7d..e7a1caabf7 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -713,13 +713,8 @@ static int bio_cf_out_write(BIO *bio, const char *buf, int blen) BIO_clear_retry_flags(bio); connssl->backend->io_result = result; if(nwritten < 0) { - if(CURLE_AGAIN == result) { + if(CURLE_AGAIN == result) BIO_set_retry_write(bio); - nwritten = 0; - } - else { - nwritten = -1; - } } return (int)nwritten; } @@ -743,13 +738,8 @@ static int bio_cf_in_read(BIO *bio, char *buf, int blen) BIO_clear_retry_flags(bio); connssl->backend->io_result = result; if(nread < 0) { - if(CURLE_AGAIN == result) { + if(CURLE_AGAIN == result) BIO_set_retry_read(bio); - nread = 0; - } - else { - nread = -1; - } } return (int)nread; } -- 2.47.3