mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Fix some problems found by Coverity scan.
This commit is contained in:
@@ -82,10 +82,6 @@ int crypt_pbkdf_check(const char *kdf, const char *hash,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Safety check if anything went wrong */
|
|
||||||
if (ms < 10)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (iter_secs)
|
if (iter_secs)
|
||||||
*iter_secs = (iterations * 1000) / ms;
|
*iter_secs = (iterations * 1000) / ms;
|
||||||
return r;
|
return r;
|
||||||
|
|||||||
@@ -1679,7 +1679,7 @@ int crypt_keyslot_change_by_passphrase(struct crypt_device *cd,
|
|||||||
r = LUKS_open_key_with_hdr(keyslot_old, passphrase, passphrase_size,
|
r = LUKS_open_key_with_hdr(keyslot_old, passphrase, passphrase_size,
|
||||||
&cd->u.luks1.hdr, &vk, cd);
|
&cd->u.luks1.hdr, &vk, cd);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
goto out;
|
||||||
|
|
||||||
if (keyslot_old != CRYPT_ANY_SLOT && keyslot_old != r) {
|
if (keyslot_old != CRYPT_ANY_SLOT && keyslot_old != r) {
|
||||||
log_dbg("Keyslot mismatch.");
|
log_dbg("Keyslot mismatch.");
|
||||||
|
|||||||
@@ -471,12 +471,16 @@ static int TCRYPT_init_hdr(struct crypt_device *cd,
|
|||||||
struct crypt_params_tcrypt *params)
|
struct crypt_params_tcrypt *params)
|
||||||
{
|
{
|
||||||
unsigned char pwd[TCRYPT_KEY_POOL_LEN] = {};
|
unsigned char pwd[TCRYPT_KEY_POOL_LEN] = {};
|
||||||
size_t passphrase_size;
|
size_t passphrase_size, alignment;
|
||||||
char *key;
|
char *key;
|
||||||
unsigned int i, skipped = 0;
|
unsigned int i, skipped = 0;
|
||||||
int r = -EINVAL, legacy_modes;
|
int r = -EINVAL, legacy_modes;
|
||||||
|
|
||||||
if (posix_memalign((void*)&key, crypt_getpagesize(), TCRYPT_HDR_KEY_LEN))
|
alignment = crypt_getpagesize();
|
||||||
|
if (alignment < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (posix_memalign((void*)&key, alignment, TCRYPT_HDR_KEY_LEN))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (params->keyfiles_count)
|
if (params->keyfiles_count)
|
||||||
|
|||||||
@@ -128,9 +128,14 @@ static int cipher_perf(struct cipher_perf *cp,
|
|||||||
{
|
{
|
||||||
long ms_enc, ms_dec, ms;
|
long ms_enc, ms_dec, ms;
|
||||||
int repeat_enc, repeat_dec;
|
int repeat_enc, repeat_dec;
|
||||||
|
size_t alignment;
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
|
|
||||||
if (posix_memalign(&buf, crypt_getpagesize(), cp->buffer_size))
|
alignment = crypt_getpagesize();
|
||||||
|
if (alignment < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (posix_memalign(&buf, alignment, cp->buffer_size))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
ms_enc = 0;
|
ms_enc = 0;
|
||||||
|
|||||||
@@ -491,10 +491,8 @@ static int action_benchmark(void)
|
|||||||
&enc_mbr, &dec_mbr);
|
&enc_mbr, &dec_mbr);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
log_std("# Algorithm | Key | Encryption | Decryption\n");
|
log_std("# Algorithm | Key | Encryption | Decryption\n");
|
||||||
strncat(cipher, "-", MAX_CIPHER_LEN);
|
log_std("%8s-%s %4db %5.1f MiB/s %5.1f MiB/s\n",
|
||||||
strncat(cipher, cipher_mode, MAX_CIPHER_LEN);
|
cipher, cipher_mode, key_size, enc_mbr, dec_mbr);
|
||||||
log_std("%12s %4db %5.1f MiB/s %5.1f MiB/s\n",
|
|
||||||
cipher, key_size, enc_mbr, dec_mbr);
|
|
||||||
} else if (r == -ENOENT)
|
} else if (r == -ENOENT)
|
||||||
log_err(_("Cipher %s is not available.\n"), opt_cipher);
|
log_err(_("Cipher %s is not available.\n"), opt_cipher);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user