Skip to content

Commit

Permalink
[core] Fix stack buffer reference after it goes out of scope (#3034).
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsantiago0 authored Oct 7, 2024
1 parent fe638be commit 62f46aa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion srtcore/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,10 @@ srt::EReadStatus srt::CChannel::recvfrom(sockaddr_any& w_addr, CPacket& w_packet
#ifndef _WIN32
msghdr mh; // will not be used on failure

#ifdef SRT_ENABLE_PKTINFO
// This buffer is mounted inside mh so it must stay in the same scope
char mh_crtl_buf[sizeof(CMSGNodeIPv4) + sizeof(CMSGNodeIPv6)];
#endif
if (select_ret > 0)
{
mh.msg_name = (w_addr.get());
Expand All @@ -878,7 +882,6 @@ srt::EReadStatus srt::CChannel::recvfrom(sockaddr_any& w_addr, CPacket& w_packet
#ifdef SRT_ENABLE_PKTINFO
// Without m_bBindMasked, we don't need ancillary data - the source
// address will always be the bound address.
char mh_crtl_buf[sizeof(CMSGNodeIPv4) + sizeof(CMSGNodeIPv6)];
if (m_bBindMasked)
{
// Extract the destination IP address from the ancillary
Expand Down

0 comments on commit 62f46aa

Please sign in to comment.