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

[core] SRTO_CONGESTION: Check optlen in getsockopt #1940

Merged

Conversation

maxsharabayko
Copy link
Collaborator

Return an error if optlen passed in srt_getsockopt(..) for SRTO_CONGESTION is not big enough to fit the string value of an option (effectively four chars + one null-terminating character).

@maxsharabayko maxsharabayko added Type: Maintenance Work required to maintain or clean up the code [core] Area: Changes in SRT library core labels Apr 14, 2021
@maxsharabayko maxsharabayko added this to the v1.4.3 milestone Apr 14, 2021
@maxsharabayko maxsharabayko self-assigned this Apr 14, 2021
@maxsharabayko
Copy link
Collaborator Author

There is one tricky part here.
Both SRTO_CONGESTION and SRTO_STREAMID expect the buffer with extra space for a zero-terminating character.
This should be described in docs.

Example

char cctype[5];
int optlen = sizeof cctype;
srt_getsockopt(sock, 0, SRTO_CONGESTION, (void*) cctype, &optlen );

// Now cctype is: "live\0", optlen is 4.

This will fail due to small buffer provided:

char cctype[4];
int optlen = sizeof cctype;
srt_getsockopt(sock, 0, SRTO_CONGESTION, (void*) cctype, &optlen ); // will return SRT_ERROR

@maxsharabayko maxsharabayko merged commit f053394 into Haivision:master Apr 15, 2021
@maxsharabayko maxsharabayko deleted the hotfix/sockopts-congestion branch April 15, 2021 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Maintenance Work required to maintain or clean up the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant