diff --git a/src/networking.c b/src/networking.c index e16a39a14..37d4bf3d3 100644 --- a/src/networking.c +++ b/src/networking.c @@ -2758,18 +2758,17 @@ NULL } } -/* HELLO [AUTH ] [SETNAME ] */ +/* HELLO [protocol-version] [AUTH ] [SETNAME ] */ void helloCommand(client *c) { - long long ver; + long long ver = 0; - if (getLongLongFromObject(c->argv[1],&ver) != C_OK || - (ver != 0 && ver < 2) || ver > 3) - { + if (c->argc >= 2 && getLongLongFromObject(c->argv[1],&ver) == C_OK && + (ver < 2 || ver > 3)) { addReplyError(c,"-NOPROTO unsupported protocol version"); return; } - for (int j = 2; j < c->argc; j++) { + for (int j = ver == 0 ? 1 : 2; j < c->argc; j++) { int moreargs = (c->argc-1) - j; const char *opt = c->argv[j]->ptr; if (!strcasecmp(opt,"AUTH") && moreargs >= 2) { diff --git a/src/sentinel.c b/src/sentinel.c index 9764f9004..1c1b4bf5b 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -469,7 +469,7 @@ struct redisCommand sentinelcmds[] = { {"client",clientCommand,-2,"admin random @connection",0,NULL,0,0,0,0,0}, {"shutdown",shutdownCommand,-1,"admin",0,NULL,0,0,0,0,0}, {"auth",authCommand,-2,"no-auth fast @connection",0,NULL,0,0,0,0,0}, - {"hello",helloCommand,-2,"no-auth fast @connection",0,NULL,0,0,0,0,0}, + {"hello",helloCommand,-1,"no-auth fast @connection",0,NULL,0,0,0,0,0}, {"acl",aclCommand,-2,"admin",0,NULL,0,0,0,0,0,0}, {"command",commandCommand,-1, "random @connection", 0,NULL,0,0,0,0,0,0} }; diff --git a/src/server.c b/src/server.c index f28c6e114..0eabe8ea2 100644 --- a/src/server.c +++ b/src/server.c @@ -869,7 +869,7 @@ struct redisCommand redisCommandTable[] = { "admin no-script random ok-loading ok-stale @connection", 0,NULL,0,0,0,0,0,0}, - {"hello",helloCommand,-2, + {"hello",helloCommand,-1, "no-auth no-script fast no-monitor ok-loading ok-stale no-slowlog @connection", 0,NULL,0,0,0,0,0,0},