mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
QUIC SSTREAM: Fix bug in ossl_quic_sstream_is_totally_acked
ossl_quic_sstream_is_totally_acked would return 0 if no data had been appended to the stream yet. Fixed and added tests. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22580)
This commit is contained in:
parent
daf26c2d7a
commit
115ee28263
@ -379,8 +379,13 @@ int ossl_quic_sstream_is_totally_acked(QUIC_SSTREAM *qss)
|
|||||||
UINT_RANGE r;
|
UINT_RANGE r;
|
||||||
uint64_t cur_size;
|
uint64_t cur_size;
|
||||||
|
|
||||||
if ((qss->have_final_size && !qss->acked_final_size)
|
if (qss->have_final_size && !qss->acked_final_size)
|
||||||
|| ossl_list_uint_set_num(&qss->acked_set) != 1)
|
return 0;
|
||||||
|
|
||||||
|
if (ossl_quic_sstream_get_cur_size(qss) == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (ossl_list_uint_set_num(&qss->acked_set) != 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = ossl_list_uint_set_head(&qss->acked_set)->range;
|
r = ossl_list_uint_set_head(&qss->acked_set)->range;
|
||||||
|
@ -48,6 +48,10 @@ static int test_sstream_simple(void)
|
|||||||
if (!TEST_ptr(sstream = ossl_quic_sstream_new(init_size)))
|
if (!TEST_ptr(sstream = ossl_quic_sstream_new(init_size)))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
/* A stream with nothing yet appended is totally acked */
|
||||||
|
if (!TEST_true(ossl_quic_sstream_is_totally_acked(sstream)))
|
||||||
|
goto err;
|
||||||
|
|
||||||
/* Should not have any data yet */
|
/* Should not have any data yet */
|
||||||
num_iov = OSSL_NELEM(iov);
|
num_iov = OSSL_NELEM(iov);
|
||||||
if (!TEST_false(ossl_quic_sstream_get_stream_frame(sstream, 0, &hdr, iov,
|
if (!TEST_false(ossl_quic_sstream_get_stream_frame(sstream, 0, &hdr, iov,
|
||||||
@ -60,6 +64,10 @@ static int test_sstream_simple(void)
|
|||||||
|| !TEST_size_t_eq(wr, sizeof(data_1)))
|
|| !TEST_size_t_eq(wr, sizeof(data_1)))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
/* No longer totally acked */
|
||||||
|
if (!TEST_false(ossl_quic_sstream_is_totally_acked(sstream)))
|
||||||
|
goto err;
|
||||||
|
|
||||||
/* Read data */
|
/* Read data */
|
||||||
num_iov = OSSL_NELEM(iov);
|
num_iov = OSSL_NELEM(iov);
|
||||||
if (!TEST_true(ossl_quic_sstream_get_stream_frame(sstream, 0, &hdr, iov,
|
if (!TEST_true(ossl_quic_sstream_get_stream_frame(sstream, 0, &hdr, iov,
|
||||||
@ -196,6 +204,9 @@ static int test_sstream_simple(void)
|
|||||||
if (!TEST_true(ossl_quic_sstream_mark_acked_fin(sstream)))
|
if (!TEST_true(ossl_quic_sstream_mark_acked_fin(sstream)))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
if (!TEST_true(ossl_quic_sstream_is_totally_acked(sstream)))
|
||||||
|
goto err;
|
||||||
|
|
||||||
testresult = 1;
|
testresult = 1;
|
||||||
err:
|
err:
|
||||||
ossl_quic_sstream_free(sstream);
|
ossl_quic_sstream_free(sstream);
|
||||||
|
Loading…
Reference in New Issue
Block a user