Skip to content
This repository has been archived by the owner on Feb 21, 2025. It is now read-only.

Commit

Permalink
SctpAssociation: fix memory violation (versatica#943)
Browse files Browse the repository at this point in the history
* SctpAssociation: fix memory violation

...when sctp debug tag is set, for SCTP_ASSOC_CHANGE notification.

Closes versatica#904

We were taking the 'sn_assoc_change.sac_info' length wrongly, unlike
for the other notifications we are logging.

- usrsctp code where the notification is created:
https://github.com/sctplab/usrsctp/blob/master/usrsctplib/netinet/sctputil.c#L3296

- Example code where this length is retrieved correctly:
https://github.com/sctplab/usrsctp/blob/master/programs/rtcweb.c#L871

* Update CHANGELOG

* normalize CHANGELOG

* be consistent with struct size retrieval
  • Loading branch information
jmillan authored and piranna committed Feb 8, 2023
1 parent ec886f2 commit 48fcf7e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Fix some libwebrtc issues (PR #944).
* Tests: Normalize hexadecimal data representation (PR #945).
* Update NPM deps.
* `SctpAssociation`: Fix memory violation (PR #943).


### 3.10.12
Expand Down
6 changes: 4 additions & 2 deletions worker/src/RTC/SctpAssociation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,8 @@ namespace RTC
static const size_t BufferSize{ 1024 };
thread_local static char buffer[BufferSize];

uint32_t len = notification->sn_header.sn_length;
uint32_t len =
notification->sn_assoc_change.sac_length - sizeof(struct sctp_assoc_change);

for (uint32_t i{ 0 }; i < len; ++i)
{
Expand Down Expand Up @@ -840,7 +841,8 @@ namespace RTC
static const size_t BufferSize{ 1024 };
thread_local static char buffer[BufferSize];

uint32_t len = notification->sn_header.sn_length;
uint32_t len =
notification->sn_assoc_change.sac_length - sizeof(struct sctp_assoc_change);

for (uint32_t i{ 0 }; i < len; ++i)
{
Expand Down

0 comments on commit 48fcf7e

Please sign in to comment.