From e0baf3d1997606855ed4ec91cf553aec11a49b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 21 Dec 2023 12:57:26 +0100 Subject: [PATCH 01/16] stream_idex --- include/srtp_priv.h | 5 ++ srtp/srtp.c | 157 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) diff --git a/include/srtp_priv.h b/include/srtp_priv.h index 8e7848989..a67aeeecf 100644 --- a/include/srtp_priv.h +++ b/include/srtp_priv.h @@ -68,6 +68,11 @@ typedef struct srtp_stream_ctx_t_ srtp_stream_ctx_t; typedef srtp_stream_ctx_t *srtp_stream_t; typedef struct srtp_stream_list_ctx_t_ *srtp_stream_list_t; +#define SRTP_STREAM_INDEX +#ifdef SRTP_STREAM_INDEX +typedef struct srtp_stream_index_ *srtp_stream_index; +#endif + /* * the following declarations are libSRTP internal functions */ diff --git a/srtp/srtp.c b/srtp/srtp.c index 2d9f6155b..2d76da09f 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -4841,8 +4841,138 @@ srtp_err_status_t srtp_get_stream_roc(srtp_t session, #ifndef SRTP_NO_STREAM_LIST +#ifdef SRTP_STREAM_INDEX + +#define INITIAL_STREAM_INDEX_SIZE 2 + +typedef struct stream_index_entry { + uint32_t ssrc; + srtp_stream_t stream; +} stream_index_entry; + +typedef struct srtp_stream_index_ { + stream_index_entry *entries; + size_t size; + size_t available; +} srtp_stream_index_; + +void srtp_stream_index_dump(srtp_stream_index stream_index) +{ + printf("stream index size: %zu\n", stream_index->size); + printf("stream index available: %zu\n", stream_index->available); + + unsigned int end = stream_index->size - stream_index->available; + unsigned int i = 0; + + for (; i < end; i++) { + printf("ssrc: %d, stream:%p\n", stream_index->entries[i].ssrc, + stream_index->entries[i].stream); + } +} +srtp_err_status_t srtp_stream_index_alloc(srtp_stream_index *stream_index_ptr) +{ + srtp_stream_index stream_index = + srtp_crypto_alloc(sizeof(srtp_stream_index_)); + if (stream_index == NULL) { + return srtp_err_status_alloc_fail; + } + + stream_index->entries = srtp_crypto_alloc(sizeof(stream_index_entry) * + INITIAL_STREAM_INDEX_SIZE); + if (stream_index->entries == NULL) { + return srtp_err_status_alloc_fail; + } + + *stream_index_ptr = stream_index; + + return srtp_err_status_ok; +} + +srtp_err_status_t srtp_stream_index_dealloc(srtp_stream_index stream_index) +{ + srtp_crypto_free(stream_index->entries); + srtp_crypto_free(stream_index); + + return srtp_err_status_ok; +} + +srtp_err_status_t srtp_stream_index_insert(srtp_stream_index stream_index, + srtp_stream_t stream) +{ + // there is no available index entry, duplicate number of entries + if (stream_index->available == 0) { + size_t new_size = stream_index->size * 2; + stream_index_entry *new_entries = + srtp_crypto_alloc(sizeof(stream_index_entry) * new_size); + if (new_entries == NULL) { + return srtp_err_status_alloc_fail; + } + + // copy previous entries into the new ones. + memcpy(new_entries, stream_index->entries, + sizeof(stream_index_entry) * stream_index->size); + // release previous entries. + srtp_crypto_free(stream_index->entries); + // assign new entries to the index. + stream_index->entries = new_entries; + // update index info. + stream_index->size = new_size; + stream_index->available = new_size / 2; + } + + // fill the first available entry + size_t next_index = stream_index->size - stream_index->available; + stream_index->entries[next_index].ssrc = stream->ssrc; + stream_index->entries[next_index].stream = stream; + + // update available value. + stream_index->available--; + + return srtp_err_status_ok; +} + +void srtp_stream_index_remove(srtp_stream_index stream_index, uint32_t ssrc) +{ + unsigned int i = 0; + unsigned int end = stream_index->size - stream_index->available; + + for (; i < end; i++) { + if (stream_index->entries[i].ssrc == ssrc) { + size_t entries_to_move = + stream_index->size - stream_index->available - i - 1; + memmove(&stream_index->entries[i], &stream_index->entries[i + 1], + entries_to_move * sizeof(stream_index_entry)); + stream_index->available++; + + break; + } + } +} + +srtp_stream_t srtp_stream_index_get(srtp_stream_index stream_index, + uint32_t ssrc) +{ + unsigned int i = 0; + unsigned int end = stream_index->size - stream_index->available; + + stream_index_entry *entries = stream_index->entries; + + for (; i < end; i++) { + if (entries[i].ssrc == ssrc) { + return entries[i].stream; + } + } + + return NULL; +} + +#endif + /* in the default implementation, we have an intrusive doubly-linked list */ typedef struct srtp_stream_list_ctx_t_ { +#ifdef SRTP_STREAM_INDEX + srtp_stream_index index; +#endif /* a stub stream that just holds pointers to the beginning and end of the * list */ srtp_stream_ctx_t data; @@ -4856,6 +4986,16 @@ srtp_err_status_t srtp_stream_list_alloc(srtp_stream_list_t *list_ptr) return srtp_err_status_alloc_fail; } +#ifdef SRTP_STREAM_INDEX + srtp_err_status_t stat = srtp_stream_index_alloc(&list->index); + if (stat) { + return stat; + } + + list->index->size = INITIAL_STREAM_INDEX_SIZE; + list->index->available = INITIAL_STREAM_INDEX_SIZE; +#endif + list->data.next = NULL; list->data.prev = NULL; @@ -4869,6 +5009,9 @@ srtp_err_status_t srtp_stream_list_dealloc(srtp_stream_list_t list) if (list->data.next) { return srtp_err_status_fail; } +#ifdef SRTP_STREAM_INDEX + srtp_stream_index_dealloc(list->index); +#endif srtp_crypto_free(list); return srtp_err_status_ok; } @@ -4884,11 +5027,21 @@ srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, list->data.next = stream; stream->prev = &(list->data); +#ifdef SRTP_STREAM_INDEX + srtp_err_status_t stat = srtp_stream_index_insert(list->index, stream); + if (stat) { + return stat; + } +#endif + return srtp_err_status_ok; } srtp_stream_t srtp_stream_list_get(srtp_stream_list_t list, uint32_t ssrc) { +#ifdef SRTP_STREAM_INDEX + return srtp_stream_index_get(list->index, ssrc); +#else /* walk down list until ssrc is found */ srtp_stream_t stream = list->data.next; while (stream != NULL) { @@ -4900,6 +5053,7 @@ srtp_stream_t srtp_stream_list_get(srtp_stream_list_t list, uint32_t ssrc) /* we haven't found our ssrc, so return a null */ return NULL; +#endif } void srtp_stream_list_remove(srtp_stream_list_t list, @@ -4911,6 +5065,9 @@ void srtp_stream_list_remove(srtp_stream_list_t list, if (stream_to_remove->next != NULL) { stream_to_remove->next->prev = stream_to_remove->prev; } +#ifdef SRTP_STREAM_INDEX + srtp_stream_index_remove(list->index, stream_to_remove->ssrc); +#endif } void srtp_stream_list_for_each(srtp_stream_list_t list, From 4887dae5871e273c22a035b8a85f28991537cf5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 21 Dec 2023 16:01:27 +0100 Subject: [PATCH 02/16] configuration --- configure | 17 +++++++++++++++++ include/srtp_priv.h | 3 +-- meson.build | 4 ++++ meson_options.txt | 2 ++ srtp/srtp.c | 14 +++++++------- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/configure b/configure index 45c3f28fc..49c69f6b6 100755 --- a/configure +++ b/configure @@ -709,6 +709,7 @@ ac_subst_files='' ac_user_opts=' enable_option_checking enable_debug_logging +enable_steam_index enable_openssl enable_nss with_openssl_dir @@ -5326,6 +5327,22 @@ fi $as_echo "$enable_debug_logging" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable stream index" >&5 +$as_echo_n "checking whether to enable stream index... " >&6; } +# Check whether --enable-stream-index was given. +if test "${enable-stream-index+set}" = set; then : + enableval=$enable_stream_index; +else + enable_stream_index=no +fi + +if test "$enable_stream_index" = "yes"; then + +$as_echo "#define ENABLE_STREAM_INDEX 1" >>confdefs.h + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_steam_index" >&5 +$as_echo "$enable_steam_index" >&6; } diff --git a/include/srtp_priv.h b/include/srtp_priv.h index a67aeeecf..3226118c3 100644 --- a/include/srtp_priv.h +++ b/include/srtp_priv.h @@ -68,8 +68,7 @@ typedef struct srtp_stream_ctx_t_ srtp_stream_ctx_t; typedef srtp_stream_ctx_t *srtp_stream_t; typedef struct srtp_stream_list_ctx_t_ *srtp_stream_list_t; -#define SRTP_STREAM_INDEX -#ifdef SRTP_STREAM_INDEX +#ifdef ENABLE_STREAM_INDEX typedef struct srtp_stream_index_ *srtp_stream_index; #endif diff --git a/meson.build b/meson.build index 81a232e61..fee0ef361 100644 --- a/meson.build +++ b/meson.build @@ -119,6 +119,10 @@ if get_option('debug-logging') cdata.set('ENABLE_DEBUG_LOGGING', true) endif +if get_option('stream-index') + cdata.set('ENABLE_STREAM_INDEX', true) +endif + use_openssl = false use_nss = false use_mbedtls = false diff --git a/meson_options.txt b/meson_options.txt index 8ff987d8e..023ed1f32 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -8,6 +8,8 @@ option('crypto-library', type: 'combo', choices : ['none', 'openssl', 'nss', 'mb description : 'What external crypto library to leverage, if any (OpenSSL, NSS, or mbedtls)') option('crypto-library-kdf', type : 'feature', value : 'auto', description : 'Use the external crypto library for Key Derivation Function support') +option('stream-index', type : 'boolean', value : 'false', + description : 'Enable stream index for fast stream retrieval') option('fuzzer', type : 'feature', value : 'disabled', description : 'Build libsrtp2 fuzzer (requires build with clang)') option('tests', type : 'feature', value : 'auto', yield : true, diff --git a/srtp/srtp.c b/srtp/srtp.c index 2d76da09f..96cea0617 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -4841,7 +4841,7 @@ srtp_err_status_t srtp_get_stream_roc(srtp_t session, #ifndef SRTP_NO_STREAM_LIST -#ifdef SRTP_STREAM_INDEX +#ifdef ENABLE_STREAM_INDEX #define INITIAL_STREAM_INDEX_SIZE 2 @@ -4970,7 +4970,7 @@ srtp_stream_t srtp_stream_index_get(srtp_stream_index stream_index, /* in the default implementation, we have an intrusive doubly-linked list */ typedef struct srtp_stream_list_ctx_t_ { -#ifdef SRTP_STREAM_INDEX +#ifdef ENABLE_STREAM_INDEX srtp_stream_index index; #endif /* a stub stream that just holds pointers to the beginning and end of the @@ -4986,7 +4986,7 @@ srtp_err_status_t srtp_stream_list_alloc(srtp_stream_list_t *list_ptr) return srtp_err_status_alloc_fail; } -#ifdef SRTP_STREAM_INDEX +#ifdef ENABLE_STREAM_INDEX srtp_err_status_t stat = srtp_stream_index_alloc(&list->index); if (stat) { return stat; @@ -5009,7 +5009,7 @@ srtp_err_status_t srtp_stream_list_dealloc(srtp_stream_list_t list) if (list->data.next) { return srtp_err_status_fail; } -#ifdef SRTP_STREAM_INDEX +#ifdef ENABLE_STREAM_INDEX srtp_stream_index_dealloc(list->index); #endif srtp_crypto_free(list); @@ -5027,7 +5027,7 @@ srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, list->data.next = stream; stream->prev = &(list->data); -#ifdef SRTP_STREAM_INDEX +#ifdef ENABLE_STREAM_INDEX srtp_err_status_t stat = srtp_stream_index_insert(list->index, stream); if (stat) { return stat; @@ -5039,7 +5039,7 @@ srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, srtp_stream_t srtp_stream_list_get(srtp_stream_list_t list, uint32_t ssrc) { -#ifdef SRTP_STREAM_INDEX +#ifdef ENABLE_STREAM_INDEX return srtp_stream_index_get(list->index, ssrc); #else /* walk down list until ssrc is found */ @@ -5065,7 +5065,7 @@ void srtp_stream_list_remove(srtp_stream_list_t list, if (stream_to_remove->next != NULL) { stream_to_remove->next->prev = stream_to_remove->prev; } -#ifdef SRTP_STREAM_INDEX +#ifdef ENABLE_STREAM_INDEX srtp_stream_index_remove(list->index, stream_to_remove->ssrc); #endif } From a1be948f01b713c22c9fae8abd1710cb68a11520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 4 Jan 2024 15:54:40 +0100 Subject: [PATCH 03/16] remove unused function --- srtp/srtp.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/srtp/srtp.c b/srtp/srtp.c index 96cea0617..cf33d4190 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -4856,19 +4856,6 @@ typedef struct srtp_stream_index_ { size_t available; } srtp_stream_index_; -void srtp_stream_index_dump(srtp_stream_index stream_index) -{ - printf("stream index size: %zu\n", stream_index->size); - printf("stream index available: %zu\n", stream_index->available); - - unsigned int end = stream_index->size - stream_index->available; - unsigned int i = 0; - - for (; i < end; i++) { - printf("ssrc: %d, stream:%p\n", stream_index->entries[i].ssrc, - stream_index->entries[i].stream); - } -} srtp_err_status_t srtp_stream_index_alloc(srtp_stream_index *stream_index_ptr) { srtp_stream_index stream_index = From ccf09509221aa69661a0a09f31d853d57ba05098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 4 Jan 2024 15:57:00 +0100 Subject: [PATCH 04/16] remove dot from comments --- srtp/srtp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/srtp/srtp.c b/srtp/srtp.c index cf33d4190..69d147bf6 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -4895,14 +4895,14 @@ srtp_err_status_t srtp_stream_index_insert(srtp_stream_index stream_index, return srtp_err_status_alloc_fail; } - // copy previous entries into the new ones. + // copy previous entries into the new ones memcpy(new_entries, stream_index->entries, sizeof(stream_index_entry) * stream_index->size); - // release previous entries. + // release previous entries srtp_crypto_free(stream_index->entries); - // assign new entries to the index. + // assign new entries to the index stream_index->entries = new_entries; - // update index info. + // update index info stream_index->size = new_size; stream_index->available = new_size / 2; } @@ -4912,7 +4912,7 @@ srtp_err_status_t srtp_stream_index_insert(srtp_stream_index stream_index, stream_index->entries[next_index].ssrc = stream->ssrc; stream_index->entries[next_index].stream = stream; - // update available value. + // update available value stream_index->available--; return srtp_err_status_ok; From b48998abac4c416cf4410838f149d407108e13e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Tue, 9 Jan 2024 10:33:48 +0100 Subject: [PATCH 05/16] release stream_index allocation on failure --- srtp/srtp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/srtp/srtp.c b/srtp/srtp.c index 69d147bf6..cc7aca34d 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -4867,6 +4867,7 @@ srtp_err_status_t srtp_stream_index_alloc(srtp_stream_index *stream_index_ptr) stream_index->entries = srtp_crypto_alloc(sizeof(stream_index_entry) * INITIAL_STREAM_INDEX_SIZE); if (stream_index->entries == NULL) { + srtp_crypto_free(stream_index); return srtp_err_status_alloc_fail; } From eba48c64a48f4babcbdaa832865279034519db6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Tue, 9 Jan 2024 15:12:03 +0100 Subject: [PATCH 06/16] define variable inside for statement --- srtp/srtp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/srtp/srtp.c b/srtp/srtp.c index cc7aca34d..5064ab28d 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -4921,10 +4921,9 @@ srtp_err_status_t srtp_stream_index_insert(srtp_stream_index stream_index, void srtp_stream_index_remove(srtp_stream_index stream_index, uint32_t ssrc) { - unsigned int i = 0; unsigned int end = stream_index->size - stream_index->available; - for (; i < end; i++) { + for (unsigned int i = 0; i < end; i++) { if (stream_index->entries[i].ssrc == ssrc) { size_t entries_to_move = stream_index->size - stream_index->available - i - 1; @@ -4940,12 +4939,11 @@ void srtp_stream_index_remove(srtp_stream_index stream_index, uint32_t ssrc) srtp_stream_t srtp_stream_index_get(srtp_stream_index stream_index, uint32_t ssrc) { - unsigned int i = 0; unsigned int end = stream_index->size - stream_index->available; stream_index_entry *entries = stream_index->entries; - for (; i < end; i++) { + for (unsigned int i = 0; i < end; i++) { if (entries[i].ssrc == ssrc) { return entries[i].stream; } From 9c8ec811a37e4980944d9bab8ab352b7a3134eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Wed, 10 Jan 2024 13:11:39 +0100 Subject: [PATCH 07/16] use new stream list if ENABLE_STREAM_INDEX --- include/srtp_priv.h | 4 - srtp/srtp.c | 272 ++++++++++++++++++++++---------------------- 2 files changed, 134 insertions(+), 142 deletions(-) diff --git a/include/srtp_priv.h b/include/srtp_priv.h index 3226118c3..8e7848989 100644 --- a/include/srtp_priv.h +++ b/include/srtp_priv.h @@ -68,10 +68,6 @@ typedef struct srtp_stream_ctx_t_ srtp_stream_ctx_t; typedef srtp_stream_ctx_t *srtp_stream_t; typedef struct srtp_stream_list_ctx_t_ *srtp_stream_list_t; -#ifdef ENABLE_STREAM_INDEX -typedef struct srtp_stream_index_ *srtp_stream_index; -#endif - /* * the following declarations are libSRTP internal functions */ diff --git a/srtp/srtp.c b/srtp/srtp.c index 5064ab28d..b3292a5ee 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -4841,127 +4841,105 @@ srtp_err_status_t srtp_get_stream_roc(srtp_t session, #ifndef SRTP_NO_STREAM_LIST -#ifdef ENABLE_STREAM_INDEX - -#define INITIAL_STREAM_INDEX_SIZE 2 - -typedef struct stream_index_entry { - uint32_t ssrc; - srtp_stream_t stream; -} stream_index_entry; - -typedef struct srtp_stream_index_ { - stream_index_entry *entries; - size_t size; - size_t available; -} srtp_stream_index_; +#ifndef ENABLE_STREAM_INDEX +/* in the default implementation, we have an intrusive doubly-linked list */ +typedef struct srtp_stream_list_ctx_t_ { + /* a stub stream that just holds pointers to the beginning and end of the + * list */ + srtp_stream_ctx_t data; +} srtp_stream_list_ctx_t_; -srtp_err_status_t srtp_stream_index_alloc(srtp_stream_index *stream_index_ptr) +srtp_err_status_t srtp_stream_list_alloc(srtp_stream_list_t *list_ptr) { - srtp_stream_index stream_index = - srtp_crypto_alloc(sizeof(srtp_stream_index_)); - if (stream_index == NULL) { - return srtp_err_status_alloc_fail; - } - - stream_index->entries = srtp_crypto_alloc(sizeof(stream_index_entry) * - INITIAL_STREAM_INDEX_SIZE); - if (stream_index->entries == NULL) { - srtp_crypto_free(stream_index); + srtp_stream_list_t list = + srtp_crypto_alloc(sizeof(srtp_stream_list_ctx_t_)); + if (list == NULL) { return srtp_err_status_alloc_fail; } - *stream_index_ptr = stream_index; + list->data.next = NULL; + list->data.prev = NULL; + *list_ptr = list; return srtp_err_status_ok; } -srtp_err_status_t srtp_stream_index_dealloc(srtp_stream_index stream_index) +srtp_err_status_t srtp_stream_list_dealloc(srtp_stream_list_t list) { - srtp_crypto_free(stream_index->entries); - srtp_crypto_free(stream_index); - + /* list must be empty */ + if (list->data.next) { + return srtp_err_status_fail; + } + srtp_crypto_free(list); return srtp_err_status_ok; } -srtp_err_status_t srtp_stream_index_insert(srtp_stream_index stream_index, - srtp_stream_t stream) +srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, + srtp_stream_t stream) { - // there is no available index entry, duplicate number of entries - if (stream_index->available == 0) { - size_t new_size = stream_index->size * 2; - stream_index_entry *new_entries = - srtp_crypto_alloc(sizeof(stream_index_entry) * new_size); - if (new_entries == NULL) { - return srtp_err_status_alloc_fail; - } - - // copy previous entries into the new ones - memcpy(new_entries, stream_index->entries, - sizeof(stream_index_entry) * stream_index->size); - // release previous entries - srtp_crypto_free(stream_index->entries); - // assign new entries to the index - stream_index->entries = new_entries; - // update index info - stream_index->size = new_size; - stream_index->available = new_size / 2; + /* insert at the head of the list */ + stream->next = list->data.next; + if (stream->next != NULL) { + stream->next->prev = stream; } - - // fill the first available entry - size_t next_index = stream_index->size - stream_index->available; - stream_index->entries[next_index].ssrc = stream->ssrc; - stream_index->entries[next_index].stream = stream; - - // update available value - stream_index->available--; + list->data.next = stream; + stream->prev = &(list->data); return srtp_err_status_ok; } -void srtp_stream_index_remove(srtp_stream_index stream_index, uint32_t ssrc) +srtp_stream_t srtp_stream_list_get(srtp_stream_list_t list, uint32_t ssrc) { - unsigned int end = stream_index->size - stream_index->available; - - for (unsigned int i = 0; i < end; i++) { - if (stream_index->entries[i].ssrc == ssrc) { - size_t entries_to_move = - stream_index->size - stream_index->available - i - 1; - memmove(&stream_index->entries[i], &stream_index->entries[i + 1], - entries_to_move * sizeof(stream_index_entry)); - stream_index->available++; - - break; + /* walk down list until ssrc is found */ + srtp_stream_t stream = list->data.next; + while (stream != NULL) { + if (stream->ssrc == ssrc) { + return stream; } + stream = stream->next; } + + /* we haven't found our ssrc, so return a null */ + return NULL; } -srtp_stream_t srtp_stream_index_get(srtp_stream_index stream_index, - uint32_t ssrc) +void srtp_stream_list_remove(srtp_stream_list_t list, + srtp_stream_t stream_to_remove) { - unsigned int end = stream_index->size - stream_index->available; - - stream_index_entry *entries = stream_index->entries; + (void)list; - for (unsigned int i = 0; i < end; i++) { - if (entries[i].ssrc == ssrc) { - return entries[i].stream; - } + stream_to_remove->prev->next = stream_to_remove->next; + if (stream_to_remove->next != NULL) { + stream_to_remove->next->prev = stream_to_remove->prev; } +} - return NULL; +void srtp_stream_list_for_each(srtp_stream_list_t list, + int (*callback)(srtp_stream_t, void *), + void *data) +{ + srtp_stream_t stream = list->data.next; + while (stream != NULL) { + srtp_stream_t tmp = stream; + stream = stream->next; + if (callback(tmp, data)) + break; + } } -#endif +#else + +#define INITIAL_STREAM_INDEX_SIZE 2 + +typedef struct list_entry { + uint32_t ssrc; + srtp_stream_t stream; +} list_entry; -/* in the default implementation, we have an intrusive doubly-linked list */ typedef struct srtp_stream_list_ctx_t_ { -#ifdef ENABLE_STREAM_INDEX - srtp_stream_index index; -#endif - /* a stub stream that just holds pointers to the beginning and end of the - * list */ - srtp_stream_ctx_t data; + list_entry *entries; + size_t size; + size_t available; } srtp_stream_list_ctx_t_; srtp_err_status_t srtp_stream_list_alloc(srtp_stream_list_t *list_ptr) @@ -4972,101 +4950,119 @@ srtp_err_status_t srtp_stream_list_alloc(srtp_stream_list_t *list_ptr) return srtp_err_status_alloc_fail; } -#ifdef ENABLE_STREAM_INDEX - srtp_err_status_t stat = srtp_stream_index_alloc(&list->index); - if (stat) { - return stat; + list->entries = + srtp_crypto_alloc(sizeof(list_entry) * INITIAL_STREAM_INDEX_SIZE); + if (list->entries == NULL) { + srtp_crypto_free(list); + return srtp_err_status_alloc_fail; } - list->index->size = INITIAL_STREAM_INDEX_SIZE; - list->index->available = INITIAL_STREAM_INDEX_SIZE; -#endif - - list->data.next = NULL; - list->data.prev = NULL; + list->size = INITIAL_STREAM_INDEX_SIZE; + list->available = INITIAL_STREAM_INDEX_SIZE; *list_ptr = list; + return srtp_err_status_ok; } srtp_err_status_t srtp_stream_list_dealloc(srtp_stream_list_t list) { /* list must be empty */ - if (list->data.next) { + if (list->available != list->size) { return srtp_err_status_fail; } -#ifdef ENABLE_STREAM_INDEX - srtp_stream_index_dealloc(list->index); -#endif + + srtp_crypto_free(list->entries); srtp_crypto_free(list); + return srtp_err_status_ok; } srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, srtp_stream_t stream) { - /* insert at the head of the list */ - stream->next = list->data.next; - if (stream->next != NULL) { - stream->next->prev = stream; - } - list->data.next = stream; - stream->prev = &(list->data); + // there is no available index entry, duplicate number of entries + if (list->available == 0) { + size_t new_size = list->size * 2; + list_entry *new_entries = + srtp_crypto_alloc(sizeof(list_entry) * new_size); + if (new_entries == NULL) { + return srtp_err_status_alloc_fail; + } -#ifdef ENABLE_STREAM_INDEX - srtp_err_status_t stat = srtp_stream_index_insert(list->index, stream); - if (stat) { - return stat; + // copy previous entries into the new ones + memcpy(new_entries, list->entries, sizeof(list_entry) * list->size); + // release previous entries + srtp_crypto_free(list->entries); + // assign new entries to the index + list->entries = new_entries; + // update index info + list->size = new_size; + list->available = new_size / 2; } -#endif + + // fill the first available entry + size_t next_index = list->size - list->available; + list->entries[next_index].ssrc = stream->ssrc; + list->entries[next_index].stream = stream; + + // update available value + list->available--; return srtp_err_status_ok; } srtp_stream_t srtp_stream_list_get(srtp_stream_list_t list, uint32_t ssrc) { -#ifdef ENABLE_STREAM_INDEX - return srtp_stream_index_get(list->index, ssrc); -#else - /* walk down list until ssrc is found */ - srtp_stream_t stream = list->data.next; - while (stream != NULL) { - if (stream->ssrc == ssrc) { - return stream; + unsigned int end = list->size - list->available; + + list_entry *entries = list->entries; + + for (unsigned int i = 0; i < end; i++) { + if (entries[i].ssrc == ssrc) { + return entries[i].stream; } - stream = stream->next; } - /* we haven't found our ssrc, so return a null */ return NULL; -#endif } void srtp_stream_list_remove(srtp_stream_list_t list, srtp_stream_t stream_to_remove) { - (void)list; + unsigned int end = list->size - list->available; - stream_to_remove->prev->next = stream_to_remove->next; - if (stream_to_remove->next != NULL) { - stream_to_remove->next->prev = stream_to_remove->prev; + for (unsigned int i = 0; i < end; i++) { + if (list->entries[i].ssrc == stream_to_remove->ssrc) { + size_t entries_to_move = list->size - list->available - i - 1; + memmove(&list->entries[i], &list->entries[i + 1], + entries_to_move * sizeof(list_entry)); + list->available++; + + break; + } } -#ifdef ENABLE_STREAM_INDEX - srtp_stream_index_remove(list->index, stream_to_remove->ssrc); -#endif } void srtp_stream_list_for_each(srtp_stream_list_t list, int (*callback)(srtp_stream_t, void *), void *data) { - srtp_stream_t stream = list->data.next; - while (stream != NULL) { - srtp_stream_t tmp = stream; - stream = stream->next; - if (callback(tmp, data)) + list_entry *entries = list->entries; + + unsigned int ssrc; + for (unsigned int i = 0; i < list->size - list->available;) { + ssrc = entries[i].ssrc; + if (callback(entries[i].stream, data)) { break; + } + + // entry was not removed, increase counter. + if (ssrc == entries[i].ssrc) { + ++i; + } } } #endif +#endif From 5f1f11dd1406205519ec4600fc6553ee1b998be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Wed, 10 Jan 2024 15:09:14 +0100 Subject: [PATCH 08/16] fix configure typo --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 49c69f6b6..8561fa704 100755 --- a/configure +++ b/configure @@ -709,7 +709,7 @@ ac_subst_files='' ac_user_opts=' enable_option_checking enable_debug_logging -enable_steam_index +enable_stream_index enable_openssl enable_nss with_openssl_dir @@ -5341,8 +5341,8 @@ if test "$enable_stream_index" = "yes"; then $as_echo "#define ENABLE_STREAM_INDEX 1" >>confdefs.h fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_steam_index" >&5 -$as_echo "$enable_steam_index" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_stream_index" >&5 +$as_echo "$enable_stream_index" >&6; } From 9d75577deec9ea179161866a2a2c609ee62a5653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 11 Jan 2024 11:06:10 +0100 Subject: [PATCH 09/16] enhance comments --- srtp/srtp.c | 59 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/srtp/srtp.c b/srtp/srtp.c index b3292a5ee..1cd3e12be 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -4978,10 +4978,17 @@ srtp_err_status_t srtp_stream_list_dealloc(srtp_stream_list_t list) return srtp_err_status_ok; } +/* + * inserting a new entry in the list may require reallocating memory in order + * to keep all the items in a contiguous memory block. + */ srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, srtp_stream_t stream) { - // there is no available index entry, duplicate number of entries + /* + * there is no space to hold the new entry in the entries buffer, + * duplicate the size of the buffer. + */ if (list->available == 0) { size_t new_size = list->size * 2; list_entry *new_entries = @@ -4990,13 +4997,13 @@ srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, return srtp_err_status_alloc_fail; } - // copy previous entries into the new ones + // copy previous entries into the new buffer memcpy(new_entries, list->entries, sizeof(list_entry) * list->size); // release previous entries srtp_crypto_free(list->entries); - // assign new entries to the index + // assign new entries to the list list->entries = new_entries; - // update index info + // update list info list->size = new_size; list->available = new_size / 2; } @@ -5012,21 +5019,11 @@ srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, return srtp_err_status_ok; } -srtp_stream_t srtp_stream_list_get(srtp_stream_list_t list, uint32_t ssrc) -{ - unsigned int end = list->size - list->available; - - list_entry *entries = list->entries; - - for (unsigned int i = 0; i < end; i++) { - if (entries[i].ssrc == ssrc) { - return entries[i].stream; - } - } - - return NULL; -} - +/* + * removing an entry from the list performs a memory move of the following + * entries one possition back in order to keep all the entries in the buffer + * contiguous. + */ void srtp_stream_list_remove(srtp_stream_list_t list, srtp_stream_t stream_to_remove) { @@ -5044,6 +5041,21 @@ void srtp_stream_list_remove(srtp_stream_list_t list, } } +srtp_stream_t srtp_stream_list_get(srtp_stream_list_t list, uint32_t ssrc) +{ + unsigned int end = list->size - list->available; + + list_entry *entries = list->entries; + + for (unsigned int i = 0; i < end; i++) { + if (entries[i].ssrc == ssrc) { + return entries[i].stream; + } + } + + return NULL; +} + void srtp_stream_list_for_each(srtp_stream_list_t list, int (*callback)(srtp_stream_t, void *), void *data) @@ -5051,13 +5063,20 @@ void srtp_stream_list_for_each(srtp_stream_list_t list, list_entry *entries = list->entries; unsigned int ssrc; + + /* + * the second statement of the expression needs to be recalculated on each + * iteration as the available number of entries may change within the given + * callback. + * Ie: in case the callback calls srtp_stream_list_remove(). + */ for (unsigned int i = 0; i < list->size - list->available;) { ssrc = entries[i].ssrc; if (callback(entries[i].stream, data)) { break; } - // entry was not removed, increase counter. + // the entry was not removed, increase the counter. if (ssrc == entries[i].ssrc) { ++i; } From 4dce2af1c84fea2464e79b21dc5011f81bff3227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 11 Jan 2024 11:17:03 +0100 Subject: [PATCH 10/16] use uint32_t type for ssrc --- srtp/srtp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srtp/srtp.c b/srtp/srtp.c index 1cd3e12be..45e58d726 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -5009,7 +5009,7 @@ srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, } // fill the first available entry - size_t next_index = list->size - list->available; + unsigned int next_index = list->size - list->available; list->entries[next_index].ssrc = stream->ssrc; list->entries[next_index].stream = stream; @@ -5062,7 +5062,7 @@ void srtp_stream_list_for_each(srtp_stream_list_t list, { list_entry *entries = list->entries; - unsigned int ssrc; + uint32_t ssrc; /* * the second statement of the expression needs to be recalculated on each From eba04366ddaeaf66ffc33f807f6b17f6e8ede9bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 11 Jan 2024 11:26:56 +0100 Subject: [PATCH 11/16] cosmetic: reorder 'memmove' arguments --- srtp/srtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srtp/srtp.c b/srtp/srtp.c index 45e58d726..4421d9918 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -5033,7 +5033,7 @@ void srtp_stream_list_remove(srtp_stream_list_t list, if (list->entries[i].ssrc == stream_to_remove->ssrc) { size_t entries_to_move = list->size - list->available - i - 1; memmove(&list->entries[i], &list->entries[i + 1], - entries_to_move * sizeof(list_entry)); + sizeof(list_entry) * entries_to_move); list->available++; break; From c5d754089766e91be21bd9fe8ee3bee1ef121b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 11 Jan 2024 12:44:11 +0100 Subject: [PATCH 12/16] remove old stream list --- configure | 19 -------- include/srtp_priv.h | 8 ---- include/stream_list_priv.h | 3 +- meson.build | 4 -- meson_options.txt | 2 - srtp/srtp.c | 92 -------------------------------------- 6 files changed, 1 insertion(+), 127 deletions(-) diff --git a/configure b/configure index 8561fa704..dac38e618 100755 --- a/configure +++ b/configure @@ -709,7 +709,6 @@ ac_subst_files='' ac_user_opts=' enable_option_checking enable_debug_logging -enable_stream_index enable_openssl enable_nss with_openssl_dir @@ -5327,24 +5326,6 @@ fi $as_echo "$enable_debug_logging" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable stream index" >&5 -$as_echo_n "checking whether to enable stream index... " >&6; } -# Check whether --enable-stream-index was given. -if test "${enable-stream-index+set}" = set; then : - enableval=$enable_stream_index; -else - enable_stream_index=no -fi - -if test "$enable_stream_index" = "yes"; then - -$as_echo "#define ENABLE_STREAM_INDEX 1" >>confdefs.h - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_stream_index" >&5 -$as_echo "$enable_stream_index" >&6; } - - diff --git a/include/srtp_priv.h b/include/srtp_priv.h index 8e7848989..87036ce12 100644 --- a/include/srtp_priv.h +++ b/include/srtp_priv.h @@ -144,14 +144,6 @@ typedef struct srtp_stream_ctx_t_ { int *enc_xtn_hdr; int enc_xtn_hdr_count; uint32_t pending_roc; - /* - The next and prev pointers are here to allow for a stream list to be - implemented as an intrusive doubly-linked list (the former being the - default). Other stream list implementations can ignore these fields or use - them for some other purpose specific to the stream list implementation. - */ - struct srtp_stream_ctx_t_ *next; - struct srtp_stream_ctx_t_ *prev; } strp_stream_ctx_t_; /* diff --git a/include/stream_list_priv.h b/include/stream_list_priv.h index b61af188e..5df0464a0 100644 --- a/include/stream_list_priv.h +++ b/include/stream_list_priv.h @@ -58,8 +58,7 @@ extern "C" { * the API was extracted to allow downstreams to override its * implementation by defining the `SRTP_NO_STREAM_LIST` preprocessor * directive, which removes the default implementation of these - * functions. if this is done, the `next` & `prev` fields are free for - * the implementation to use. + * functions. * * this is still an internal interface; there is no stability * guarantee--downstreams should watch this file for changes in diff --git a/meson.build b/meson.build index fee0ef361..81a232e61 100644 --- a/meson.build +++ b/meson.build @@ -119,10 +119,6 @@ if get_option('debug-logging') cdata.set('ENABLE_DEBUG_LOGGING', true) endif -if get_option('stream-index') - cdata.set('ENABLE_STREAM_INDEX', true) -endif - use_openssl = false use_nss = false use_mbedtls = false diff --git a/meson_options.txt b/meson_options.txt index 023ed1f32..8ff987d8e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -8,8 +8,6 @@ option('crypto-library', type: 'combo', choices : ['none', 'openssl', 'nss', 'mb description : 'What external crypto library to leverage, if any (OpenSSL, NSS, or mbedtls)') option('crypto-library-kdf', type : 'feature', value : 'auto', description : 'Use the external crypto library for Key Derivation Function support') -option('stream-index', type : 'boolean', value : 'false', - description : 'Enable stream index for fast stream retrieval') option('fuzzer', type : 'feature', value : 'disabled', description : 'Build libsrtp2 fuzzer (requires build with clang)') option('tests', type : 'feature', value : 'auto', yield : true, diff --git a/srtp/srtp.c b/srtp/srtp.c index 4421d9918..6d923abd0 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -593,9 +593,6 @@ static srtp_err_status_t srtp_stream_clone( str->enc_xtn_hdr = stream_template->enc_xtn_hdr; str->enc_xtn_hdr_count = stream_template->enc_xtn_hdr_count; - /* defensive coding */ - str->next = NULL; - str->prev = NULL; return srtp_err_status_ok; } @@ -4841,94 +4838,6 @@ srtp_err_status_t srtp_get_stream_roc(srtp_t session, #ifndef SRTP_NO_STREAM_LIST -#ifndef ENABLE_STREAM_INDEX -/* in the default implementation, we have an intrusive doubly-linked list */ -typedef struct srtp_stream_list_ctx_t_ { - /* a stub stream that just holds pointers to the beginning and end of the - * list */ - srtp_stream_ctx_t data; -} srtp_stream_list_ctx_t_; - -srtp_err_status_t srtp_stream_list_alloc(srtp_stream_list_t *list_ptr) -{ - srtp_stream_list_t list = - srtp_crypto_alloc(sizeof(srtp_stream_list_ctx_t_)); - if (list == NULL) { - return srtp_err_status_alloc_fail; - } - - list->data.next = NULL; - list->data.prev = NULL; - - *list_ptr = list; - return srtp_err_status_ok; -} - -srtp_err_status_t srtp_stream_list_dealloc(srtp_stream_list_t list) -{ - /* list must be empty */ - if (list->data.next) { - return srtp_err_status_fail; - } - srtp_crypto_free(list); - return srtp_err_status_ok; -} - -srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, - srtp_stream_t stream) -{ - /* insert at the head of the list */ - stream->next = list->data.next; - if (stream->next != NULL) { - stream->next->prev = stream; - } - list->data.next = stream; - stream->prev = &(list->data); - - return srtp_err_status_ok; -} - -srtp_stream_t srtp_stream_list_get(srtp_stream_list_t list, uint32_t ssrc) -{ - /* walk down list until ssrc is found */ - srtp_stream_t stream = list->data.next; - while (stream != NULL) { - if (stream->ssrc == ssrc) { - return stream; - } - stream = stream->next; - } - - /* we haven't found our ssrc, so return a null */ - return NULL; -} - -void srtp_stream_list_remove(srtp_stream_list_t list, - srtp_stream_t stream_to_remove) -{ - (void)list; - - stream_to_remove->prev->next = stream_to_remove->next; - if (stream_to_remove->next != NULL) { - stream_to_remove->next->prev = stream_to_remove->prev; - } -} - -void srtp_stream_list_for_each(srtp_stream_list_t list, - int (*callback)(srtp_stream_t, void *), - void *data) -{ - srtp_stream_t stream = list->data.next; - while (stream != NULL) { - srtp_stream_t tmp = stream; - stream = stream->next; - if (callback(tmp, data)) - break; - } -} - -#else - #define INITIAL_STREAM_INDEX_SIZE 2 typedef struct list_entry { @@ -5084,4 +4993,3 @@ void srtp_stream_list_for_each(srtp_stream_list_t list, } #endif -#endif From 1f23e07b50417f220b974b3ab61d1bc755fa7792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 11 Jan 2024 12:50:13 +0100 Subject: [PATCH 13/16] configure: put back two extra blank lines --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index dac38e618..45c3f28fc 100755 --- a/configure +++ b/configure @@ -5330,6 +5330,8 @@ $as_echo "$enable_debug_logging" >&6; } + + if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. From 3e0c6ecbd41a2d428166b2ca5d30fcbf11260c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 11 Jan 2024 17:16:55 +0100 Subject: [PATCH 14/16] srtp_stream_list_for_each: rely on available entries Since this function is used to iterate and remove the entries in the list, rely on list availability to increase the loop counter. NOTE: Previously 'ssrc' was checked, but this breaks the case were there are multiple entries with the same 'ssrc'. --- srtp/srtp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/srtp/srtp.c b/srtp/srtp.c index 6d923abd0..760c63b10 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -4971,7 +4971,7 @@ void srtp_stream_list_for_each(srtp_stream_list_t list, { list_entry *entries = list->entries; - uint32_t ssrc; + size_t available = list->available; /* * the second statement of the expression needs to be recalculated on each @@ -4980,15 +4980,16 @@ void srtp_stream_list_for_each(srtp_stream_list_t list, * Ie: in case the callback calls srtp_stream_list_remove(). */ for (unsigned int i = 0; i < list->size - list->available;) { - ssrc = entries[i].ssrc; if (callback(entries[i].stream, data)) { break; } // the entry was not removed, increase the counter. - if (ssrc == entries[i].ssrc) { + if (available == list->available) { ++i; } + + available = list->available; } } From a7b6b7e9fb1caefcd02dcdae3cc614be1cdd27d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 11 Jan 2024 17:28:06 +0100 Subject: [PATCH 15/16] fix windows warnings --- srtp/srtp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/srtp/srtp.c b/srtp/srtp.c index 760c63b10..048e32348 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -4918,7 +4918,7 @@ srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, } // fill the first available entry - unsigned int next_index = list->size - list->available; + size_t next_index = list->size - list->available; list->entries[next_index].ssrc = stream->ssrc; list->entries[next_index].stream = stream; @@ -4936,7 +4936,7 @@ srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, void srtp_stream_list_remove(srtp_stream_list_t list, srtp_stream_t stream_to_remove) { - unsigned int end = list->size - list->available; + size_t end = list->size - list->available; for (unsigned int i = 0; i < end; i++) { if (list->entries[i].ssrc == stream_to_remove->ssrc) { @@ -4952,7 +4952,7 @@ void srtp_stream_list_remove(srtp_stream_list_t list, srtp_stream_t srtp_stream_list_get(srtp_stream_list_t list, uint32_t ssrc) { - unsigned int end = list->size - list->available; + size_t end = list->size - list->available; list_entry *entries = list->entries; From 1828b47f6aa0d4ac1a7aebcb69a7fb6e963c82ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Fri, 12 Jan 2024 10:58:08 +0100 Subject: [PATCH 16/16] enhance comment --- srtp/srtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srtp/srtp.c b/srtp/srtp.c index 048e32348..2f25decee 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -4896,7 +4896,7 @@ srtp_err_status_t srtp_stream_list_insert(srtp_stream_list_t list, { /* * there is no space to hold the new entry in the entries buffer, - * duplicate the size of the buffer. + * double the size of the buffer. */ if (list->available == 0) { size_t new_size = list->size * 2;