mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-13 20:00:08 +01:00
Check exit value for snprintf where it makes sense.
This commit is contained in:
11
lib/setup.c
11
lib/setup.c
@@ -1079,10 +1079,15 @@ static int _init_by_name_crypt_none(struct crypt_device *cd)
|
||||
_mode);
|
||||
|
||||
if (!r) {
|
||||
snprintf(cd->u.none.cipher_spec, sizeof(cd->u.none.cipher_spec),
|
||||
r = snprintf(cd->u.none.cipher_spec, sizeof(cd->u.none.cipher_spec),
|
||||
"%s-%s", cd->u.none.cipher, _mode);
|
||||
cd->u.none.cipher_mode = cd->u.none.cipher_spec + strlen(cd->u.none.cipher) + 1;
|
||||
cd->u.none.key_size = tgt->u.crypt.vk->keylength;
|
||||
if (r < 0 || (size_t)r >= sizeof(cd->u.none.cipher_spec))
|
||||
r = -EINVAL;
|
||||
else {
|
||||
cd->u.none.cipher_mode = cd->u.none.cipher_spec + strlen(cd->u.none.cipher) + 1;
|
||||
cd->u.none.key_size = tgt->u.crypt.vk->keylength;
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
|
||||
dm_targets_free(cd, &dmd);
|
||||
|
||||
Reference in New Issue
Block a user