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

STUNErrorCodeAttribute System.ArgumentException #797

Open
uler3161 opened this issue Jul 21, 2022 · 1 comment
Open

STUNErrorCodeAttribute System.ArgumentException #797

uler3161 opened this issue Jul 21, 2022 · 1 comment

Comments

@uler3161
Copy link

Been working on a project to forward RTSP streams over WebRTC. Pretty new to all this, so bear with me. The logging output and research I've done makes it seem that I need to be using a TURN server (not just a STUN server). Was using Stuntman before. Now using Pion. And I'm using version 6.0.9 of sipsorcery.

So, what's happening is that I apparently don't have TURN authentication set up right yet. As a result, Pion is sending a 401 unauthenticated error. Found that out by looking at a Wireshark trace. The STUNAttribute class is correctly parsing the attribute type as an error code. This particular error (and maybe others in the STUN protocol?) seems to send 4 bytes. The first two, according to Wireshark, are reserved as 0x0000. Then comes 0x04 (Error Class: 4). Finally, 0x01 (Error Code: 1).

These 4 bytes are then passed to the constructor of STUNErrorCodeAttribute. The first thing it does is this:

ErrorClass = (byte)BitConverter.ToChar(attributeValue, 2);

Unfortunately, BitConverter.ToChar apparently reads a unicode char, so this code is reading 2 bytes starting at position 2. Which I believe means it's reading the last 2 bytes. I think it should only read the next to last byte.

Then, the next line is where the ArgumentException happens (specifically that the destination array is not long enough):

ErrorNumber = (byte)BitConverter.ToChar(attributeValue, 3)

I think this should be reading the last byte, but seems to be reading the last byte and then trying to read past the end of the array.

@malegend
Copy link

I have the same issue too...
PLEAZE how did you solve it?

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

No branches or pull requests

3 participants