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]: Fixed validation of input parameters in srt_connect #2520

Merged
merged 2 commits into from
Nov 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ SRTSOCKET srt::CUDTUnited::accept(const SRTSOCKET listen, sockaddr* pw_addr, int
int srt::CUDTUnited::connect(SRTSOCKET u, const sockaddr* srcname, const sockaddr* tarname, int namelen)
{
// Here both srcname and tarname must be specified
if (!srcname || !tarname || size_t(namelen) < sizeof(sockaddr_in))
if (!srcname || !tarname || namelen < int(sizeof(sockaddr_in)))
{
LOGC(aclog.Error,
log << "connect(with source): invalid call: srcname=" << srcname << " tarname=" << tarname
Expand Down Expand Up @@ -1224,6 +1224,12 @@ int srt::CUDTUnited::connect(SRTSOCKET u, const sockaddr* srcname, const sockadd

int srt::CUDTUnited::connect(const SRTSOCKET u, const sockaddr* name, int namelen, int32_t forced_isn)
{
if (!name || namelen < int(sizeof(sockaddr_in)))
{
LOGC(aclog.Error, log << "connect(): invalid call: name=" << name << " namelen=" << namelen);
throw CUDTException(MJ_NOTSUP, MN_INVAL);
}

sockaddr_any target_addr(name, namelen);
if (target_addr.len == 0)
throw CUDTException(MJ_NOTSUP, MN_INVAL, 0);
Expand Down