redis-cli fixes around help hints version filtering (#13097)
- In removeUnsupportedArgs, trying to access the next item after the last one and causing an out of bounds read. - In versionIsSupported, when the 'version' is equal to 'since', the return value is 0 (not supported). Also, change the function to return `not supported` in case they have different numbers of digits Both issues were found by `Non-interactive non-TTY CLI: Test command-line hinting - old server` under `test-sanitizer-address` (When changing the `src/version.h` locally to `8.0.0`) The new `MAXAGE` argument inside `client-kill` triggered the issue (new argument at the end of the list) --------- Co-authored-by: YaacovHazan <yaacov.hazan@redislabs.com>
This commit is contained in:
parent
4cae99e785
commit
a50bbcb656
@ -745,8 +745,13 @@ static int versionIsSupported(sds version, sds since) {
|
||||
}
|
||||
versionPos = strchr(versionPos, '.');
|
||||
sincePos = strchr(sincePos, '.');
|
||||
if (!versionPos || !sincePos)
|
||||
return 0;
|
||||
|
||||
/* If we finished to parse both `version` and `since`, it means they are equal */
|
||||
if (!versionPos && !sincePos) return 1;
|
||||
|
||||
/* Different number of digits considered as not supported */
|
||||
if (!versionPos || !sincePos) return 0;
|
||||
|
||||
versionPos++;
|
||||
sincePos++;
|
||||
}
|
||||
@ -763,7 +768,7 @@ static void removeUnsupportedArgs(struct cliCommandArg *args, int *numargs, sds
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
for (j = i; j != *numargs; j++) {
|
||||
for (j = i; j != *numargs - 1; j++) {
|
||||
args[j] = args[j + 1];
|
||||
}
|
||||
(*numargs)--;
|
||||
|
Loading…
x
Reference in New Issue
Block a user