You are not allowed to set a subkey expire if the subkey does not exist

Former-commit-id: 12e17cfd6e9cc1e470f26c88b58ce5831d10358f
This commit is contained in:
John Sully 2019-10-13 14:11:43 -04:00
parent 0e82cb44e5
commit 6310847d61

View File

@ -156,7 +156,7 @@ void expireMemberCore(client *c, robj *key, robj *subkey, long long basetime, lo
when += basetime; when += basetime;
/* No key, return zero. */ /* No key, return zero. */
dictEntry *de = dictFind(c->db->pdict, szFromObj(c->argv[1])); dictEntry *de = dictFind(c->db->pdict, szFromObj(key));
if (de == NULL) { if (de == NULL) {
addReply(c,shared.czero); addReply(c,shared.czero);
return; return;
@ -167,7 +167,10 @@ void expireMemberCore(client *c, robj *key, robj *subkey, long long basetime, lo
switch (val->type) switch (val->type)
{ {
case OBJ_SET: case OBJ_SET:
// these types are safe if (!setTypeIsMember(val, szFromObj(subkey))) {
addReplyError(c, "subkey does not exist");
return;
}
break; break;
default: default:
@ -175,7 +178,7 @@ void expireMemberCore(client *c, robj *key, robj *subkey, long long basetime, lo
return; return;
} }
setExpire(c, c->db, c->argv[1], c->argv[2], when); setExpire(c, c->db, key, subkey, when);
addReply(c, shared.ok); addReply(c, shared.ok);
} }