diff --git a/tests/api.c b/tests/api.c index a6ca181bc..1e352c833 100644 --- a/tests/api.c +++ b/tests/api.c @@ -31230,6 +31230,10 @@ static int test_wolfSSL_a2i_ASN1_INTEGER(void) AssertNotNull(fixed = BIO_new(wolfSSL_BIO_s_fixed_mem())); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); + /* Ensure there is 0 bytes avaialble to write into. */ + AssertIntEQ(BIO_write(fixed, tmp, 1), 1); + AssertIntEQ(i2a_ASN1_INTEGER(fixed, ai), 0); + AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(i2a_ASN1_INTEGER(fixed, ai), 0); BIO_free(fixed); @@ -31954,7 +31958,9 @@ static int test_wolfSSL_ASN1_STRING_print(void) BIO_free(bio); AssertNotNull(bio = BIO_new(wolfSSL_BIO_s_fixed_mem())); - AssertIntEQ(BIO_set_write_buf_size(bio, 0), 1); + AssertIntEQ(BIO_set_write_buf_size(bio, 1), 1); + /* Ensure there is 0 bytes avaialble to write into. */ + AssertIntEQ(BIO_write(bio, rbuf, 1), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print(bio, asnStr), 0); AssertIntEQ(BIO_set_write_buf_size(bio, 1), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print(bio, asnStr), 0); @@ -32017,6 +32023,10 @@ static int test_wolfSSL_ASN1_STRING_print_ex(void) BIO_read(bio, (void*)rbuf, 15); AssertStrEQ((char*)rbuf, "Hello wolfSSL!"); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); + /* Ensure there is 0 bytes avaialble to write into. */ + AssertIntEQ(BIO_write(fixed, rbuf, 1), 1); + AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); + AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 14), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); @@ -32029,6 +32039,10 @@ static int test_wolfSSL_ASN1_STRING_print_ex(void) BIO_read(bio, (void*)rbuf, 9); AssertStrEQ((char*)rbuf, "a\\+\\;\\<\\>"); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); + /* Ensure there is 0 bytes avaialble to write into. */ + AssertIntEQ(BIO_write(fixed, rbuf, 1), 1); + AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, esc_str, flags), 0); + AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, esc_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 8), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, esc_str, flags), 0); @@ -32041,6 +32055,10 @@ static int test_wolfSSL_ASN1_STRING_print_ex(void) BIO_read(bio, (void*)rbuf, 28); AssertStrEQ((char*)rbuf, "OCTET STRING:Hello wolfSSL!"); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); + /* Ensure there is 0 bytes avaialble to write into. */ + AssertIntEQ(BIO_write(fixed, rbuf, 1), 1); + AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); + AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 12), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); @@ -32055,6 +32073,10 @@ static int test_wolfSSL_ASN1_STRING_print_ex(void) BIO_read(bio, (void*)rbuf, 31); AssertStrEQ((char*)rbuf, "#48656C6C6F20776F6C6653534C2100"); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); + /* Ensure there is 0 bytes avaialble to write into. */ + AssertIntEQ(BIO_write(fixed, rbuf, 1), 1); + AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); + AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 30), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); @@ -32067,6 +32089,10 @@ static int test_wolfSSL_ASN1_STRING_print_ex(void) BIO_read(bio, (void*)rbuf, 35); AssertStrEQ((char*)rbuf, "#040F48656C6C6F20776F6C6653534C2100"); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); + /* Ensure there is 0 bytes avaialble to write into. */ + AssertIntEQ(BIO_write(fixed, rbuf, 1), 1); + AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); + AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 2), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); @@ -32225,6 +32251,10 @@ static int test_wolfSSL_ASN1_GENERALIZEDTIME_print(void) BIO_free(bio); AssertNotNull(bio = BIO_new(wolfSSL_BIO_s_fixed_mem())); + AssertIntEQ(BIO_set_write_buf_size(bio, 1), 1); + /* Ensure there is 0 bytes avaialble to write into. */ + AssertIntEQ(BIO_write(bio, buf, 1), 1); + AssertIntEQ(wolfSSL_ASN1_GENERALIZEDTIME_print(bio, >ime), 0); for (i = 1; i < 20; i++) { AssertIntEQ(BIO_set_write_buf_size(bio, i), 1); AssertIntEQ(wolfSSL_ASN1_GENERALIZEDTIME_print(bio, >ime), 0); @@ -32668,6 +32698,10 @@ static int test_wolfSSL_ASN1_TIME_print(void) /* Test BIO_write fails. */ AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); + /* Ensure there is 0 bytes avaialble to write into. */ + AssertIntEQ(BIO_write(fixed, buf, 1), 1); + AssertIntEQ(ASN1_TIME_print(fixed, notBefore), 0); + AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(ASN1_TIME_print(fixed, notBefore), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 23), 1); AssertIntEQ(ASN1_TIME_print(fixed, notBefore), 0);