From 6db5cb844852f8f13753caf26dea7750f701e4d9 Mon Sep 17 00:00:00 2001 From: Hugo Landau Date: Wed, 12 Oct 2022 17:44:40 +0100 Subject: QUIC CFQ Fixes Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/19206) --- ssl/quic/quic_cfq.c | 21 ++++++++++++--------- ssl/quic/quic_txpim.c | 7 ++++--- 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'ssl') diff --git a/ssl/quic/quic_cfq.c b/ssl/quic/quic_cfq.c index 0b0651289a..54acbedce8 100644 --- a/ssl/quic/quic_cfq.c +++ b/ssl/quic/quic_cfq.c @@ -20,38 +20,38 @@ struct quic_cfq_item_ex_st { uint64_t frame_type; size_t encoded_len; uint32_t priority, pn_space; - char state; + int state; }; -uint64_t ossl_quic_cfq_item_get_frame_type(QUIC_CFQ_ITEM *item) +uint64_t ossl_quic_cfq_item_get_frame_type(const QUIC_CFQ_ITEM *item) { QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item; return ex->frame_type; } -const unsigned char *ossl_quic_cfq_item_get_encoded(QUIC_CFQ_ITEM *item) +const unsigned char *ossl_quic_cfq_item_get_encoded(const QUIC_CFQ_ITEM *item) { QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item; return ex->encoded; } -size_t ossl_quic_cfq_item_get_encoded_len(QUIC_CFQ_ITEM *item) +size_t ossl_quic_cfq_item_get_encoded_len(const QUIC_CFQ_ITEM *item) { QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item; return ex->encoded_len; } -int ossl_quic_cfq_item_get_state(QUIC_CFQ_ITEM *item) +int ossl_quic_cfq_item_get_state(const QUIC_CFQ_ITEM *item) { QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item; return ex->state; } -uint32_t ossl_quic_cfq_item_get_pn_space(QUIC_CFQ_ITEM *item) +uint32_t ossl_quic_cfq_item_get_pn_space(const QUIC_CFQ_ITEM *item) { QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item; @@ -161,6 +161,7 @@ static void list_insert_sorted(QUIC_CFQ_ITEM_LIST *l, QUIC_CFQ_ITEM_EX *n, QUIC_CFQ *ossl_quic_cfq_new(void) { QUIC_CFQ *cfq = OPENSSL_zalloc(sizeof(*cfq)); + if (cfq == NULL) return NULL; @@ -297,6 +298,7 @@ void ossl_quic_cfq_mark_lost(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item, void ossl_quic_cfq_release(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item) { QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item; + switch (ex->state) { case QUIC_CFQ_STATE_NEW: list_remove(&cfq->new_list, ex); @@ -314,19 +316,20 @@ void ossl_quic_cfq_release(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item) } } -QUIC_CFQ_ITEM *ossl_quic_cfq_get_priority_head(QUIC_CFQ *cfq, uint32_t pn_space) +QUIC_CFQ_ITEM *ossl_quic_cfq_get_priority_head(const QUIC_CFQ *cfq, + uint32_t pn_space) { QUIC_CFQ_ITEM_EX *item = cfq->new_list.head; for (; item != NULL && item->pn_space != pn_space; item = item->next); if (item == NULL) - return NULL; /* ubsan */ + return NULL; return &item->public; } -QUIC_CFQ_ITEM *ossl_quic_cfq_item_get_priority_next(QUIC_CFQ_ITEM *item, +QUIC_CFQ_ITEM *ossl_quic_cfq_item_get_priority_next(const QUIC_CFQ_ITEM *item, uint32_t pn_space) { QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item; diff --git a/ssl/quic/quic_txpim.c b/ssl/quic/quic_txpim.c index 9693758769..3a7662292b 100644 --- a/ssl/quic/quic_txpim.c +++ b/ssl/quic/quic_txpim.c @@ -34,6 +34,7 @@ struct quic_txpim_st { QUIC_TXPIM *ossl_quic_txpim_new(void) { QUIC_TXPIM *txpim = OPENSSL_zalloc(sizeof(*txpim)); + if (txpim == NULL) return NULL; @@ -198,7 +199,7 @@ static int compare(const void *a, const void *b) return 0; } -const QUIC_TXPIM_CHUNK *ossl_quic_txpim_pkt_get_chunks(QUIC_TXPIM_PKT *fpkt) +const QUIC_TXPIM_CHUNK *ossl_quic_txpim_pkt_get_chunks(const QUIC_TXPIM_PKT *fpkt) { QUIC_TXPIM_PKT_EX *ex = (QUIC_TXPIM_PKT_EX *)fpkt; @@ -214,14 +215,14 @@ const QUIC_TXPIM_CHUNK *ossl_quic_txpim_pkt_get_chunks(QUIC_TXPIM_PKT *fpkt) return ex->chunks; } -size_t ossl_quic_txpim_pkt_get_num_chunks(QUIC_TXPIM_PKT *fpkt) +size_t ossl_quic_txpim_pkt_get_num_chunks(const QUIC_TXPIM_PKT *fpkt) { QUIC_TXPIM_PKT_EX *ex = (QUIC_TXPIM_PKT_EX *)fpkt; return ex->num_chunks; } -size_t ossl_quic_txpim_get_in_use(QUIC_TXPIM *txpim) +size_t ossl_quic_txpim_get_in_use(const QUIC_TXPIM *txpim) { return txpim->in_use; } -- cgit v1.2.3