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
This commit is contained in:
Daniel Stenberg 2022-12-05 11:29:38 +01:00
parent 0ed8ff2d37
commit 5ec759247a
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -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;
}