Skip to content

Commit

Permalink
[core] Fixed getting SRTO_RCVBUF and SRTO_SNDBUF on a group.
Browse files Browse the repository at this point in the history
The documented length is 4 bytes, the code was setting 8 bytes without checking `optlen`.
  • Loading branch information
maxsharabayko committed Nov 20, 2024
1 parent 3931af6 commit 5f16494
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions srtcore/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ template <size_t N>
static void importStringOption(vector<CUDTGroup::ConfigItem>& storage, SRT_SOCKOPT optname, const StringStorage<N>& optval)
{
if (optval.empty())
return;
return;

// Store the option when:
// - option has a value (default is empty).
Expand Down Expand Up @@ -615,9 +615,11 @@ bool CUDTGroup::applyFlags(uint32_t flags, HandshakeSide)
template <class Type>
struct Value
{
static int fill(void* optval, int, const Type& value)
static int fill(void* optval, int len, const Type& value)
{
// XXX assert size >= sizeof(Type) ?
if (size_t(len) < sizeof(Type))
return 0;

*(Type*)optval = value;
return sizeof(Type);
}
Expand Down Expand Up @@ -671,7 +673,7 @@ static bool getOptDefault(SRT_SOCKOPT optname, void* pw_optval, int& w_optlen)

case SRTO_SNDBUF:
case SRTO_RCVBUF:
w_optlen = fillValue((pw_optval), w_optlen, CSrtConfig::DEF_BUFFER_SIZE * (CSrtConfig::DEF_MSS - CPacket::UDP_HDR_SIZE));
w_optlen = fillValue<int>((pw_optval), w_optlen, CSrtConfig::DEF_BUFFER_SIZE * (CSrtConfig::DEF_MSS - CPacket::UDP_HDR_SIZE));
break;

case SRTO_LINGER:
Expand Down

0 comments on commit 5f16494

Please sign in to comment.