From f0c7cfa459082768235db764b2847ae850ea9d33 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 11 Feb 2019 17:00:51 +0100 Subject: [PATCH] ACL: return error when removing a non existing password. Otherwise it's very simple for an human mistake to think a password is removed because of a typo in the ACL SETUSER myuser passwords,delpass); - if (ln) listDelNode(u->passwords,ln); sdsfree(delpass); + if (ln) { + listDelNode(u->passwords,ln); + } else { + errno = ENODEV; + return C_ERR; + } } else if (op[0] == '~') { if (u->flags & USER_FLAG_ALLKEYS) { errno = EEXIST; @@ -810,6 +816,9 @@ char *ACLSetUserStringError(void) { "'allkeys' flag) is not valid and does not have any " "effect. Try 'resetkeys' to start with an empty " "list of patterns"; + else if (errno == ENODEV) + errmsg = "The password you are trying to remove from the user does " + "not exist"; return errmsg; }