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.
This commit is contained in:
Binbin 2021-07-06 15:46:10 +08:00 committed by GitHub
parent 5ea3c3db15
commit 3a26f61fb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2777,7 +2777,8 @@ void replicaofCommand(client *c) {
return; 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; return;
/* Check if we are already attached to the specified master */ /* Check if we are already attached to the specified master */