Fix off by one bug in LUKS2 keyslot max id allocation.

This is almost impossible to hit bug. The max keyslot id is
checked in higher layer.
This commit is contained in:
Ondrej Kozina
2018-04-10 16:30:15 +02:00
committed by Milan Broz
parent 255c8e8ff4
commit 3616ee50c0

View File

@@ -400,7 +400,7 @@ int luks2_keyslot_alloc(struct crypt_device *cd,
if (keyslot == CRYPT_ANY_SLOT)
keyslot = LUKS2_keyslot_find_empty(hdr, "luks2");
if (keyslot < 0 || keyslot > LUKS2_KEYSLOTS_MAX)
if (keyslot < 0 || keyslot >= LUKS2_KEYSLOTS_MAX)
return -ENOMEM;
if (LUKS2_get_keyslot_jobj(hdr, keyslot)) {