From: Dr. David von Oheimb Date: Sat, 12 Jun 2021 09:49:22 +0000 (+0200) Subject: BIO_write_ex(): Make handing of BIO b == NULL and dlen == 0 less redundant X-Git-Tag: openssl-3.0.0-beta1~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb19b9d4561228599b2259f6a4912066274ae622;p=thirdparty%2Fopenssl.git BIO_write_ex(): Make handing of BIO b == NULL and dlen == 0 less redundant Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15722) --- diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c index af7ad05bcab..a378f186d7b 100644 --- a/crypto/bio/bio_lib.c +++ b/crypto/bio/bio_lib.c @@ -393,13 +393,8 @@ int BIO_write(BIO *b, const void *data, int dlen) int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written) { - if (dlen == 0) { - /* no error */ - if (written != NULL) - *written = 0; - return 1; - } - return bio_write_intern(b, data, dlen, written) > 0; + return bio_write_intern(b, data, dlen, written) > 0 + || (b != NULL && dlen == 0); /* order is important for *written */ } int BIO_puts(BIO *b, const char *buf)