diff --git a/src/ssl.c b/src/ssl.c index 255ec7cc8..95e228442 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -14913,7 +14913,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) { WOLFSSL_BIO* bio = NULL; - if (buf == NULL || len < 0) { + if (buf == NULL) { return bio; } @@ -14922,6 +14922,9 @@ int wolfSSL_set_compression(WOLFSSL* ssl) return bio; } + if (len < 0) { + len = XSTRLEN(buf); + } bio->num = bio->wrSz = len; bio->ptr = (byte*)XMALLOC(len, 0, DYNAMIC_TYPE_OPENSSL); if (bio->ptr == NULL) { diff --git a/tests/api.c b/tests/api.c index c230c3c4a..507d59116 100644 --- a/tests/api.c +++ b/tests/api.c @@ -24983,10 +24983,9 @@ static void test_wolfSSL_BIO_gets(void) /* try with bad args */ AssertNull(bio = BIO_new_mem_buf(NULL, sizeof(msg))); - AssertNull(bio = BIO_new_mem_buf((void*)msg, -1)); /* try with real msg */ - AssertNotNull(bio = BIO_new_mem_buf((void*)msg, sizeof(msg))); + AssertNotNull(bio = BIO_new_mem_buf((void*)msg, -1)); XMEMSET(bio_buffer, 0, bufferSz); AssertNotNull(BIO_push(bio, BIO_new(BIO_s_bio()))); AssertNull(bio2 = BIO_find_type(bio, BIO_TYPE_FILE));