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;
|
||||
}
|
||||
|
||||
/* Safety check if anything went wrong */
|
||||
if (ms < 10)
|
||||
return -EINVAL;
|
||||
|
||||
if (iter_secs)
|
||||
*iter_secs = (iterations * 1000) / ms;
|
||||
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,
|
||||
&cd->u.luks1.hdr, &vk, cd);
|
||||
if (r < 0)
|
||||
return r;
|
||||
goto out;
|
||||
|
||||
if (keyslot_old != CRYPT_ANY_SLOT && keyslot_old != r) {
|
||||
log_dbg("Keyslot mismatch.");
|
||||
|
||||
@@ -471,12 +471,16 @@ static int TCRYPT_init_hdr(struct crypt_device *cd,
|
||||
struct crypt_params_tcrypt *params)
|
||||
{
|
||||
unsigned char pwd[TCRYPT_KEY_POOL_LEN] = {};
|
||||
size_t passphrase_size;
|
||||
size_t passphrase_size, alignment;
|
||||
char *key;
|
||||
unsigned int i, skipped = 0;
|
||||
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;
|
||||
|
||||
if (params->keyfiles_count)
|
||||
|
||||
@@ -128,9 +128,14 @@ static int cipher_perf(struct cipher_perf *cp,
|
||||
{
|
||||
long ms_enc, ms_dec, ms;
|
||||
int repeat_enc, repeat_dec;
|
||||
size_t alignment;
|
||||
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;
|
||||
|
||||
ms_enc = 0;
|
||||
|
||||
@@ -491,10 +491,8 @@ static int action_benchmark(void)
|
||||
&enc_mbr, &dec_mbr);
|
||||
if (!r) {
|
||||
log_std("# Algorithm | Key | Encryption | Decryption\n");
|
||||
strncat(cipher, "-", MAX_CIPHER_LEN);
|
||||
strncat(cipher, cipher_mode, MAX_CIPHER_LEN);
|
||||
log_std("%12s %4db %5.1f MiB/s %5.1f MiB/s\n",
|
||||
cipher, key_size, enc_mbr, dec_mbr);
|
||||
log_std("%8s-%s %4db %5.1f MiB/s %5.1f MiB/s\n",
|
||||
cipher, cipher_mode, key_size, enc_mbr, dec_mbr);
|
||||
} else if (r == -ENOENT)
|
||||
log_err(_("Cipher %s is not available.\n"), opt_cipher);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user