From 321e840c1c35bfca8dfd3d534dc2bb0b8576f709 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Wed, 25 Apr 2018 14:59:36 +0200 Subject: [PATCH] Fix some signed/unsigned warnings. --- lib/setup.c | 7 ++++--- src/cryptsetup.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/setup.c b/lib/setup.c index 25b4e602..1a22f5aa 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -1476,7 +1476,7 @@ static int _crypt_format_luks2(struct crypt_device *cd, size_t volume_key_size, struct crypt_params_luks2 *params) { - int r; + int r, integrity_key_size; unsigned long required_alignment = DEFAULT_DISK_ALIGNMENT; unsigned long alignment_offset = 0; unsigned int sector_size = params ? params->sector_size : SECTOR_SIZE; @@ -1515,7 +1515,8 @@ static int _crypt_format_luks2(struct crypt_device *cd, else return -EINVAL; } - if (INTEGRITY_key_size(cd, integrity) >= volume_key_size) { + integrity_key_size = INTEGRITY_key_size(cd, integrity); + if ((integrity_key_size < 0) || (integrity_key_size >= (int)volume_key_size)) { log_err(cd, _("Volume key is too small for encryption with integrity extensions.\n")); return -EINVAL; } @@ -3395,7 +3396,7 @@ int crypt_volume_key_get(struct crypt_device *cd, if (key_len < 0) return -EINVAL; - if (key_len > *volume_key_size) { + if (key_len > (int)*volume_key_size) { log_err(cd, _("Volume key buffer too small.\n")); return -ENOMEM; } diff --git a/src/cryptsetup.c b/src/cryptsetup.c index cea04881..8d2bf337 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -1210,7 +1210,7 @@ static int action_luksKillSlot(void) break; case CRYPT_SLOT_INACTIVE: log_err(_("Keyslot %d is not active."), opt_key_slot); - /* pass through */ + /* fall through */ case CRYPT_SLOT_INVALID: return -EINVAL; }