summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2022-11-30 01:56:19 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2022-11-30 01:56:19 +0000
commitca6f4a8bfed8f85365290b14d147baab3a73ffbc (patch)
treeffbabd65f47fa781a45a1bdb725b506fbc46c488 /lib
parentc8a3ded82f50aa26c8fb4f4c6be2f34257763d22 (diff)
Mostly align BIO_read()/BIO_write() return values with OpenSSL 3.x.
For various historical reasons, there are a number of cases where our BIO_read() and BIO_write() return slightly different values to what OpenSSL 3.x does (of course OpenSSL 1.0 differs from OpenSSL 1.1 which differs from OpenSSL 3.x). Mostly align these - some further work will be needed. Issue raised by tb@ who also wrote some test code.
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/bio/bio_lib.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/libcrypto/bio/bio_lib.c b/lib/libcrypto/bio/bio_lib.c
index 92c0d5eb1c3..b33ebe167bf 100644
--- a/lib/libcrypto/bio/bio_lib.c
+++ b/lib/libcrypto/bio/bio_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bio_lib.c,v 1.37 2022/11/28 07:50:00 tb Exp $ */
+/* $OpenBSD: bio_lib.c,v 1.38 2022/11/30 01:56:18 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -322,12 +322,19 @@ BIO_read(BIO *b, void *out, int outl)
size_t readbytes = 0;
int ret;
- if (b == NULL)
- return (0);
+ if (b == NULL) {
+ BIOerror(ERR_R_PASSED_NULL_PARAMETER);
+ return (-1);
+ }
- if (out == NULL || outl <= 0)
+ if (outl <= 0)
return (0);
+ if (out == NULL) {
+ BIOerror(ERR_R_PASSED_NULL_PARAMETER);
+ return (-1);
+ }
+
if (b->method == NULL || b->method->bread == NULL) {
BIOerror(BIO_R_UNSUPPORTED_METHOD);
return (-2);
@@ -372,12 +379,19 @@ BIO_write(BIO *b, const void *in, int inl)
size_t writebytes = 0;
int ret;
- if (b == NULL)
- return (0);
+ if (b == NULL) {
+ BIOerror(ERR_R_PASSED_NULL_PARAMETER);
+ return (-1);
+ }
- if (in == NULL || inl <= 0)
+ if (inl <= 0)
return (0);
+ if (in == NULL) {
+ BIOerror(ERR_R_PASSED_NULL_PARAMETER);
+ return (-1);
+ }
+
if (b->method == NULL || b->method->bwrite == NULL) {
BIOerror(BIO_R_UNSUPPORTED_METHOD);
return (-2);