From e8e6edf93b40deb55ed20e7ad0bf287a86fc972f Mon Sep 17 00:00:00 2001 From: Sandro Date: Fri, 5 Jan 2024 15:22:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86Sctp=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E8=B6=8A=E7=95=8C=E5=92=8C=E5=A4=9A=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E9=9D=99=E6=80=81buffer=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/SctpAssociation.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/webrtc/SctpAssociation.cpp b/webrtc/SctpAssociation.cpp index d07931c6..1b5d2782 100644 --- a/webrtc/SctpAssociation.cpp +++ b/webrtc/SctpAssociation.cpp @@ -674,15 +674,14 @@ namespace RTC case SCTP_COMM_LOST: { - auto offset = (char *)¬ification->sn_assoc_change.sac_info[0] - (char *)notification; - auto len = (ptrdiff_t)notification->sn_assoc_change.sac_length - offset; - - if (len > 0) + if (notification->sn_header.sn_length > 0) { static const size_t BufferSize{ 1024 }; - static char buffer[BufferSize]; + thread_local static char buffer[BufferSize]; - for (uint32_t i{ 0 }; i < (uint32_t)len; ++i) + uint32_t len = notification->sn_assoc_change.sac_length - sizeof(struct sctp_assoc_change); + + for (uint32_t i{ 0 }; i < len; ++i) { std::snprintf( buffer, BufferSize, " 0x%02x", notification->sn_assoc_change.sac_info[i]); @@ -743,15 +742,14 @@ namespace RTC case SCTP_CANT_STR_ASSOC: { - auto offset = (char *)¬ification->sn_assoc_change.sac_info[0] - (char *)notification; - auto len = (ptrdiff_t)notification->sn_assoc_change.sac_length - offset; - - if (len > 0) + if (notification->sn_header.sn_length > 0) { static const size_t BufferSize{ 1024 }; - static char buffer[BufferSize]; + thread_local static char buffer[BufferSize]; - for (uint32_t i{ 0 }; i < (uint32_t)len; ++i) + uint32_t len = notification->sn_assoc_change.sac_length - sizeof(struct sctp_assoc_change); + + for (uint32_t i{ 0 }; i < len; ++i) { std::snprintf( buffer, BufferSize, " 0x%02x", notification->sn_assoc_change.sac_info[i]); @@ -788,7 +786,7 @@ namespace RTC case SCTP_REMOTE_ERROR: { static const size_t BufferSize{ 1024 }; - static char buffer[BufferSize]; + thread_local static char buffer[BufferSize]; uint32_t len = notification->sn_remote_error.sre_length - sizeof(struct sctp_remote_error); @@ -824,7 +822,7 @@ namespace RTC case SCTP_SEND_FAILED_EVENT: { static const size_t BufferSize{ 1024 }; - static char buffer[BufferSize]; + thread_local static char buffer[BufferSize]; uint32_t len = notification->sn_send_failed_event.ssfe_length - sizeof(struct sctp_send_failed_event); @@ -1006,4 +1004,4 @@ namespace RTC } // namespace RTC -#endif //ENABLE_SCTP \ No newline at end of file +#endif //ENABLE_SCTP