summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhwware <wen.hui.ware@gmail.com>2020-03-29 23:20:54 -0400
committerantirez <antirez@gmail.com>2020-04-07 16:52:04 +0200
commitb35407fa7c5e43ce184c89abb50134e816292907 (patch)
tree47ff25d3dad2487e3a094b21094fb4dec2983a2e
parent4395889c9e13b0f0909372780fd1d6ecad7fb61a (diff)
downloadredis-b35407fa7c5e43ce184c89abb50134e816292907.tar.gz
add check for not switching between optin optout mode directly
-rw-r--r--src/networking.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/networking.c b/src/networking.c
index f8808f08f..85c640e34 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -2326,7 +2326,7 @@ NULL
return;
}
- if ((options & CLIENT_TRACKING_OPTIN) && (options & CLIENT_TRACKING_OPTOUT))
+ if (options & CLIENT_TRACKING_OPTIN && options & CLIENT_TRACKING_OPTOUT)
{
addReplyError(c,
"You can't specify both OPTIN mode and OPTOUT mode");
@@ -2334,6 +2334,17 @@ NULL
return;
}
+ if ((options & CLIENT_TRACKING_OPTIN && c->flags & CLIENT_TRACKING_OPTOUT) ||
+ (options & CLIENT_TRACKING_OPTOUT && c->flags & CLIENT_TRACKING_OPTIN))
+ {
+ addReplyError(c,
+ "You can't switch OPTIN/OPTOUT mode before disabling "
+ "tracking for this client, and then re-enabling it with "
+ "a different mode.");
+ zfree(prefix);
+ return;
+ }
+
enableTracking(c,redir,options,prefix,numprefix);
} else if (!strcasecmp(c->argv[2]->ptr,"off")) {
disableTracking(c);