From 7d6594d2f9b81127c716d00721d6e42aa97512f4 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 21 Jan 2025 15:25:36 -0400 Subject: [PATCH] MT#55283 safeguard against incorrect usage If keyspace notifications are not configured at all, bail with an error when there is an attempt to add a new keyspace or remove one. We get a segfault otherwise. Closes #1902 Change-Id: Ie47cf5f7762792aabe38476739f0dcf9927787ce (cherry picked from commit 6dbf098bc70f995c56118dc2022bdf0c1ba21449) (cherry picked from commit 96f5adaee1d4d829f603bb1583d494c1f8e11612) --- daemon/cli.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/daemon/cli.c b/daemon/cli.c index b34dff3cd..6f97a446b 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -1046,6 +1046,11 @@ static void cli_incoming_ksadd(str *instr, struct cli_writer *cw) { unsigned long uint_keyspace_db; char *endptr; + if (!rtpe_redis_notify) { + cw->cw_printf(cw, "Keyspace notification feature has not been configured.\n"); + return; + } + if (str_shift(instr, 1)) { cw->cw_printf(cw, "%s\n", "More parameters required."); return; @@ -1076,6 +1081,11 @@ static void cli_incoming_ksrm(str *instr, struct cli_writer *cw) { unsigned long uint_keyspace_db; char *endptr; + if (!rtpe_redis_notify) { + cw->cw_printf(cw, "Keyspace notification feature has not been configured.\n"); + return; + } + if (str_shift(instr, 1)) { cw->cw_printf(cw, "%s\n", "More parameters required."); return; @@ -1110,6 +1120,11 @@ static void cli_incoming_ksrm(str *instr, struct cli_writer *cw) { static void cli_incoming_kslist(str *instr, struct cli_writer *cw) { GList *l; + if (!rtpe_redis_notify) { + cw->cw_printf(cw, "Keyspace notification feature has not been configured.\n"); + return; + } + cw->cw_printf(cw, "\nSubscribed-on keyspaces:\n"); rwlock_lock_r(&rtpe_config.keyspaces_lock);