ACL: handle command IDs in case insensitive way.
This commit is contained in:
parent
94460440b7
commit
dbdc68a658
13
src/acl.c
13
src/acl.c
@ -284,10 +284,17 @@ unsigned long ACLGetCommandID(const char *cmdname) {
|
||||
static rax *map = NULL;
|
||||
static unsigned long nextid = 0;
|
||||
|
||||
sds lowername = sdsnew(cmdname);
|
||||
sdstolower(lowername);
|
||||
if (map == NULL) map = raxNew();
|
||||
void *id = raxFind(map,(unsigned char*)cmdname,strlen(cmdname));
|
||||
if (id != raxNotFound) return (unsigned long)id;
|
||||
raxInsert(map,(unsigned char*)cmdname,strlen(cmdname),(void*)nextid,NULL);
|
||||
void *id = raxFind(map,(unsigned char*)lowername,sdslen(lowername));
|
||||
if (id != raxNotFound) {
|
||||
sdsfree(lowername);
|
||||
return (unsigned long)id;
|
||||
}
|
||||
raxInsert(map,(unsigned char*)lowername,strlen(lowername),
|
||||
(void*)nextid,NULL);
|
||||
sdsfree(lowername);
|
||||
return nextid++;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user