Skip to content

Commit

Permalink
[core] Fixed validation of input parameters in srt_connect (#2520).
Browse files Browse the repository at this point in the history
Parameters: name and namelen.
  • Loading branch information
ThibaultBee authored Nov 9, 2022
1 parent 932e5bd commit e082f30
Showing 1 changed file with 7 additions and 1 deletion.
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

0 comments on commit e082f30

Please sign in to comment.