The branch master has been updated via 541d4f19957727d331c2e4353a26841f5d1fe32d (commit) via 20778ea7dad8c4f659dbb5dfcb4fac896e51ed6a (commit) via 451c2a95bd7b21677efedb7c4a8860d3178a5f65 (commit) from 814b5133e9aca90f1edb99c38a26e55cd7e50e19 (commit)
- Log ----------------------------------------------------------------- commit 541d4f19957727d331c2e4353a26841f5d1fe32d Author: Tomas Mraz <to...@openssl.org> Date: Thu Jun 10 16:55:37 2021 +0200 fuzz/asn1parse: Use BIO_s_mem() as fallback output /dev/null is not available everywhere. Reviewed-by: Paul Dale <pa...@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15672) commit 20778ea7dad8c4f659dbb5dfcb4fac896e51ed6a Author: Tomas Mraz <to...@openssl.org> Date: Wed Jun 9 13:48:21 2021 +0200 BIO_write_ex: No error only on 0 bytes to write Fixes #15682 Reviewed-by: Paul Dale <pa...@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15672) commit 451c2a95bd7b21677efedb7c4a8860d3178a5f65 Author: Tomas Mraz <to...@openssl.org> Date: Wed Jun 9 12:27:51 2021 +0200 Windows CI: Enable fuzz test in plain build Reviewed-by: Paul Dale <pa...@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15672) ----------------------------------------------------------------------- Summary of changes: .github/workflows/windows.yml | 2 +- crypto/bio/bio_lib.c | 8 +++++++- doc/man3/BIO_read.pod | 7 +++++-- fuzz/asn1parse.c | 2 ++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index bcfa45a4ba..5c98695a70 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -57,7 +57,7 @@ jobs: run: nmake /S - name: test working-directory: _build - run: nmake test VERBOSE_FAILURE=yes TESTS=-test_fuzz* HARNESS_JOBS=4 + run: nmake test VERBOSE_FAILURE=yes HARNESS_JOBS=4 minimal: runs-on: windows-latest steps: diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c index cdce122796..af7ad05bca 100644 --- a/crypto/bio/bio_lib.c +++ b/crypto/bio/bio_lib.c @@ -393,7 +393,13 @@ 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) { - return bio_write_intern(b, data, dlen, written) >= 0; + if (dlen == 0) { + /* no error */ + if (written != NULL) + *written = 0; + return 1; + } + return bio_write_intern(b, data, dlen, written) > 0; } int BIO_puts(BIO *b, const char *buf) diff --git a/doc/man3/BIO_read.pod b/doc/man3/BIO_read.pod index 08104b1b92..a2d8ab3af0 100644 --- a/doc/man3/BIO_read.pod +++ b/doc/man3/BIO_read.pod @@ -27,7 +27,7 @@ stored in I<*readbytes>. BIO_write_ex() attempts to write I<dlen> bytes from I<data> to BIO I<b>. If successful then the number of bytes written is stored in I<*written> -unless I<written> is NULL. No data is written if I<b> is NULL. +unless I<written> is NULL. BIO_read() attempts to read I<len> bytes from BIO I<b> and places the data in I<buf>. @@ -59,7 +59,7 @@ BIO_puts() attempts to write a NUL-terminated string I<buf> to BIO I<b>. BIO_read_ex() returns 1 if data was successfully read, and 0 otherwise. BIO_write_ex() returns 1 if no error was encountered writing data, 0 otherwise. -Write to NULL B<BIO> is not considered as an error. +Requesting to write 0 bytes is not considered an error. BIO_write() returns -2 if the "write" operation is not implemented by the BIO or -1 on other errors. @@ -114,6 +114,9 @@ keep the '\n' at the end of the line in the buffer. BIO_get_line() was added in OpenSSL 3.0. +BIO_write_ex() returns 1 if the size of the data to write is 0 and the +I<written> parameter of the function can be NULL since OpenSSL 3.0. + =head1 COPYRIGHT Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved. diff --git a/fuzz/asn1parse.c b/fuzz/asn1parse.c index ac888e535a..72b0df8a46 100644 --- a/fuzz/asn1parse.c +++ b/fuzz/asn1parse.c @@ -24,6 +24,8 @@ static BIO *bio_out; int FuzzerInitialize(int *argc, char ***argv) { bio_out = BIO_new_file("/dev/null", "w"); + if (bio_out == NULL) + bio_out = BIO_new(BIO_s_mem()); OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); ERR_clear_error(); CRYPTO_free_ex_index(0, -1);