diff options
author | Milan Broz <gmazyland@gmail.com> | 2012-12-10 17:28:52 +0100 |
---|---|---|
committer | Milan Broz <gmazyland@gmail.com> | 2012-12-10 17:28:52 +0100 |
commit | 80d21c039e784e6b693a5e78069816ca6f9b7939 (patch) | |
tree | b5ef18b491ef4fec396d8d7a778b448b7a840308 | |
parent | 549ab6435806fe48206f9051f2acd13829030c27 (diff) | |
download | cryptsetup-80d21c039e784e6b693a5e78069816ca6f9b7939.tar.gz cryptsetup-80d21c039e784e6b693a5e78069816ca6f9b7939.tar.bz2 cryptsetup-80d21c039e784e6b693a5e78069816ca6f9b7939.zip |
Fix some problems found by Coverity scan.
-rw-r--r-- | lib/crypto_backend/pbkdf_check.c | 4 | ||||
-rw-r--r-- | lib/setup.c | 2 | ||||
-rw-r--r-- | lib/tcrypt/tcrypt.c | 8 | ||||
-rw-r--r-- | lib/utils_benchmark.c | 7 | ||||
-rw-r--r-- | src/cryptsetup.c | 6 |
5 files changed, 15 insertions, 12 deletions
diff --git a/lib/crypto_backend/pbkdf_check.c b/lib/crypto_backend/pbkdf_check.c index 69f6bfb..ce5bd1e 100644 --- a/lib/crypto_backend/pbkdf_check.c +++ b/lib/crypto_backend/pbkdf_check.c @@ -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; diff --git a/lib/setup.c b/lib/setup.c index 5e01f99..5914f9d 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -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."); diff --git a/lib/tcrypt/tcrypt.c b/lib/tcrypt/tcrypt.c index b1ebd05..1672c71 100644 --- a/lib/tcrypt/tcrypt.c +++ b/lib/tcrypt/tcrypt.c @@ -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) diff --git a/lib/utils_benchmark.c b/lib/utils_benchmark.c index 4ee0c03..f392382 100644 --- a/lib/utils_benchmark.c +++ b/lib/utils_benchmark.c @@ -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; diff --git a/src/cryptsetup.c b/src/cryptsetup.c index d652bad..4592897 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -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 { |