Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buffer overflow when handling large signalling descriptions #62

Merged
merged 2 commits into from
Jul 15, 2024

Conversation

alufers
Copy link
Contributor

@alufers alufers commented Jul 12, 2024

This can happen when a computer has lots of network interfaces, for example when running docker.

This is the signalling JSON from my PC:

{"type":"answer", "sdp":"v=0\r\no=rtc 190772944 0 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic:WMS *\r\na=ice-options:ice2,trickle\r\na=fingerprint:sha-256 14:C6:74:62:AF:64:75:F9:07:30:5B:F5:13:06:BD:0A:2F:E1:69:A3:2E:83:43:9E:93:57:FF:51:0E:70:D7:CD\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=mid:0\r\na=sendrecv\r\na=sctp-port:5000\r\na=max-message-size:262144\r\na=setup:active\r\na=ice-ufrag:HRcS\r\na=ice-pwd:npVVI0DyEA2/KXM7q/u3r4\r\na=candidate:9 1 UDP 2130704383 fdbf:cd27:1133::9 60386 typ host\r\na=candidate:1 1 UDP 2122317823 X.X.X.X 60386 typ host\r\na=candidate:2 1 UDP 2122317567 X.X.X.X 60386 typ host\r\na=candidate:3 1 UDP 2122317311 172.18.0.1 60386 typ host\r\na=candidate:4 1 UDP 2122317055 172.23.0.1 60386 typ host\r\na=candidate:5 1 UDP 2122316799 172.19.0.1 60386 typ host\r\na=candidate:6 1 UDP 2122316543 172.20.0.1 60386 typ host\r\na=candidate:7 1 UDP 2122316287 172.25.0.1 60386 typ host\r\na=candidate:8 1 UDP 2122316031 172.26.0.1 60386 typ host\r\na=end-of-candidates\r\n"}

it did not fit in the 1024 byte buffer, so I changed it to a dynamically allocated one on the heap. This code runs only when establishing a connection, so some dynamic allocation is not that bad.

This can happen when a computer has lots of network interfaces, for example
when running docker.
Copy link
Owner

@nathhB nathhB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments

net_drivers/webrtc_c.h Outdated Show resolved Hide resolved
net_drivers/webrtc_c.h Outdated Show resolved Hide resolved
@alufers
Copy link
Contributor Author

alufers commented Jul 15, 2024

Addressed comments. Sorry for missing that, I was in a bit of a rush to finish a project for uni and didn't notice that :)

@alufers alufers requested a review from nathhB July 15, 2024 11:33
@nathhB nathhB merged commit 01f8213 into nathhB:master Jul 15, 2024
17 of 18 checks passed
@nathhB
Copy link
Owner

nathhB commented Jul 15, 2024

@alufers thank you very much for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants