From a7b3711a8a862e697f641b296743cc7c921f5fba Mon Sep 17 00:00:00 2001 From: Sektor van Skijlen Date: Thu, 26 Sep 2024 18:23:22 +0200 Subject: [PATCH] [core] Fixed nonchecked empty config for packetfilter (#3031). --- srtcore/common.cpp | 2 ++ test/test_fec_rebuilding.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/srtcore/common.cpp b/srtcore/common.cpp index d3fd4f22c..2e94668ae 100644 --- a/srtcore/common.cpp +++ b/srtcore/common.cpp @@ -446,6 +446,8 @@ bool SrtParseConfig(const string& s, SrtConfig& w_config) vector parts; Split(s, ',', back_inserter(parts)); + if (parts.empty()) + return false; w_config.type = parts[0]; diff --git a/test/test_fec_rebuilding.cpp b/test/test_fec_rebuilding.cpp index ac57e5265..7e1499212 100644 --- a/test/test_fec_rebuilding.cpp +++ b/test/test_fec_rebuilding.cpp @@ -222,7 +222,9 @@ TEST(TestFEC, ConfigExchange) char fec_config1 [] = "fec,cols:10,rows:10"; - srt_setsockflag(sid1, SRTO_PACKETFILTER, fec_config1, (sizeof fec_config1)-1); + // Check empty configuration first + EXPECT_EQ(srt_setsockflag(sid1, SRTO_PACKETFILTER, "", 0), -1); + EXPECT_NE(srt_setsockflag(sid1, SRTO_PACKETFILTER, fec_config1, (sizeof fec_config1)-1), -1); EXPECT_TRUE(m1.checkApplyFilterConfig("fec,cols:10,arq:never"));