From bd0c473be271aca9eee6021ed85fe1a0920d2453 Mon Sep 17 00:00:00 2001 From: Sandro Date: Thu, 4 Jan 2024 19:24:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86Sctp=E7=9A=84?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E8=AE=BF=E9=97=AE=E8=B6=8A=E7=95=8C=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/SctpAssociation.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/webrtc/SctpAssociation.cpp b/webrtc/SctpAssociation.cpp index 84a2c04f..d07931c6 100644 --- a/webrtc/SctpAssociation.cpp +++ b/webrtc/SctpAssociation.cpp @@ -674,14 +674,15 @@ namespace RTC case SCTP_COMM_LOST: { - if (notification->sn_header.sn_length > 0) + 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) { static const size_t BufferSize{ 1024 }; static char buffer[BufferSize]; - uint32_t len = notification->sn_header.sn_length; - - for (uint32_t i{ 0 }; i < len; ++i) + for (uint32_t i{ 0 }; i < (uint32_t)len; ++i) { std::snprintf( buffer, BufferSize, " 0x%02x", notification->sn_assoc_change.sac_info[i]); @@ -742,14 +743,15 @@ namespace RTC case SCTP_CANT_STR_ASSOC: { - if (notification->sn_header.sn_length > 0) + 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) { static const size_t BufferSize{ 1024 }; static char buffer[BufferSize]; - uint32_t len = notification->sn_header.sn_length; - - for (uint32_t i{ 0 }; i < len; ++i) + for (uint32_t i{ 0 }; i < (uint32_t)len; ++i) { std::snprintf( buffer, BufferSize, " 0x%02x", notification->sn_assoc_change.sac_info[i]);