From 0f2eaff9bbb6455988476fe0c33269841cd81f04 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Mon, 18 May 2026 09:52:04 +0200 Subject: [PATCH] MT#61856 main: rtpe_config, check `0 <= silence_detect <= 100` Check that `silence_detect` is in the range 0-100. Also properly cast to actual `silence_detect_int` type which is `uint32_t`. The reason is that in the current code this can exceed `INT_MAX` (for values near or above 50%) and also, values above 100% are not rejected. Change-Id: Ic2359402879412926b18125e292c1969cda45203 --- daemon/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/daemon/main.c b/daemon/main.c index f3fffff7c..b08063149 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -1330,9 +1330,14 @@ static void options(int *argc, char ***argv, charp_ht templates) { rtpe_config.jb_adaptive_min, rtpe_config.jb_adaptive_max); } - if (silence_detect > 0) { + if (silence_detect > 0 && silence_detect < 100) { rtpe_config.silence_detect_double = silence_detect / 100.0; - rtpe_config.silence_detect_int = (int) ((silence_detect / 100.0) * UINT32_MAX); + rtpe_config.silence_detect_int = (uint32_t) ((silence_detect / 100.0) * UINT32_MAX); + } + else if (silence_detect != 0) { + /* all what's < 0 and > 100 */ + ilog(LOG_WARN, "Invalid --silence-detect value given (%f), must be in range 1-100", + silence_detect); } parse_cn_payload(&rtpe_config.cn_payload, cn_payload, "\x20", "cn-payload");