diff options
author | antirez <antirez@gmail.com> | 2019-02-04 13:00:38 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2019-02-04 13:00:58 +0100 |
commit | b166c41eddec664e64c1e268266d38c3f26edaa2 (patch) | |
tree | 3696d1528fda1f89093b507394fe4bf790ab62ed /src/acl.c | |
parent | 21e84cdae254b715b15e48734fbd8484b2c14810 (diff) | |
download | redis-b166c41eddec664e64c1e268266d38c3f26edaa2.tar.gz |
ACL: make ACLAppendUserForLoading() able to report bad argument.
Diffstat (limited to 'src/acl.c')
-rw-r--r-- | src/acl.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -931,9 +931,16 @@ int ACLCheckCommandPerm(client *c) { * * Note that this function cannot stop in case of commands that are not found * and, in that case, the error will be emitted later, because certain - * commands may be defined later once modules are loaded. */ -int ACLAppendUserForLoading(sds *argv, int argc) { - if (argc < 2 || strcasecmp(argv[0],"user")) return C_ERR; + * commands may be defined later once modules are loaded. + * + * When an error is detected and C_ERR is returned, the function populates + * by reference (if not set to NULL) the argc_err argument with the index + * of the argv vector that caused the error. */ +int ACLAppendUserForLoading(sds *argv, int argc, int *argc_err) { + if (argc < 2 || strcasecmp(argv[0],"user")) { + if (argc_err) *argc_err = 0; + return C_ERR; + } /* Try to apply the user rules in a fake user to see if they * are actually valid. */ @@ -947,6 +954,7 @@ int ACLAppendUserForLoading(sds *argv, int argc) { if (ACLSetUser(fakeuser,argv[j],sdslen(argv[j])) == C_ERR) { if (errno != ENOENT) { ACLFreeUser(fakeuser); + if (argc_err) *argc_err = j; return C_ERR; } } |