Skip to content

Commit 52ceecd

Browse files
SPAlekseyClément Gérouville
andauthored
Fix SIGABRT when bonding option is too long (#3210)
* Fix SIGABRT when bonding option is too long * Move the UT to test_bonding.cpp --------- Co-authored-by: Clément Gérouville <cgerouville@haivision.com>
1 parent 9b97cfa commit 52ceecd

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

srtcore/socketconfig.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ bool SRT_SocketOptionObject::add(SRT_SOCKOPT optname, const void* optval, size_t
10921092
// needed - and it's better to not risk that alighment rules
10931093
// will make these calculations result in less space than needed.
10941094
const size_t headersize = sizeof(SingleOption);
1095-
const size_t payload = std::min(sizeof(uint32_t), optlen);
1095+
const size_t payload = std::max(sizeof(uint32_t), optlen);
10961096
unsigned char* mem = new unsigned char[headersize + payload];
10971097
SingleOption* option = reinterpret_cast<SingleOption*>(mem);
10981098
option->option = optname;

test/test_bonding.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,3 +1594,12 @@ TEST(Bonding, BackupPrioritySelection)
15941594
}
15951595

15961596

1597+
TEST(Bonding, ApiConfig)
1598+
{
1599+
using namespace std;
1600+
SRT_SOCKOPT_CONFIG config;
1601+
1602+
string example = "example_long_excessively";
1603+
1604+
EXPECT_EQ(srt_config_add(&config, SRTO_BINDTODEVICE, (void*)example.data(), example.size()), 0);
1605+
}

test/test_utilities.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,4 @@ TEST(ConfigString, Setting)
272272
EXPECT_EQ(s.size(), 0U);
273273
EXPECT_TRUE(s.empty());
274274
}
275+

0 commit comments

Comments
 (0)