From 3a26f61fb35ff9f96da8b7d0ba7d5f8c73e46da5 Mon Sep 17 00:00:00 2001 From: Binbin Date: Tue, 6 Jul 2021 15:46:10 +0800 Subject: [PATCH] Add range check for master port in replicaof. (#9201) So that we can avoid commands that are obviously wrong. Also unified with loadServerConfigFromString because we also checked the range. --- src/replication.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/replication.c b/src/replication.c index 06934a7bb..65e6d9b08 100644 --- a/src/replication.c +++ b/src/replication.c @@ -2777,7 +2777,8 @@ void replicaofCommand(client *c) { return; } - if ((getLongFromObjectOrReply(c, c->argv[2], &port, NULL) != C_OK)) + if (getRangeLongFromObjectOrReply(c, c->argv[2], 0, 65535, &port, + "Invalid master port") != C_OK) return; /* Check if we are already attached to the specified master */