summaryrefslogtreecommitdiffstats
path: root/src/cryptsetup
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-12-19 08:51:12 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2017-12-19 08:51:12 +0100
commitdc0a35550e898f9ca1c7b64a36911235da74ce83 (patch)
tree793113375d7a3478a1d472c5fa4dd245fdeef467 /src/cryptsetup
parentanalyze: use normal bus connection for "plot" verb (#7685) (diff)
downloadsystemd-dc0a35550e898f9ca1c7b64a36911235da74ce83.tar.xz
systemd-dc0a35550e898f9ca1c7b64a36911235da74ce83.zip
cryptsetup: use uint64_t for keyfile-offset= (#7689)
On 32bit, refuse large offsets. Once https://gitlab.com/cryptsetup/cryptsetup/issues/359 is resolved, we should switch to the new api, whatever it is. Fixes #7677.
Diffstat (limited to 'src/cryptsetup')
-rw-r--r--src/cryptsetup/cryptsetup.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index 21c51022ef..7255ff418c 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -47,7 +47,7 @@ static char *arg_cipher = NULL;
static unsigned arg_key_size = 0;
static int arg_key_slot = CRYPT_ANY_SLOT;
static unsigned arg_keyfile_size = 0;
-static unsigned arg_keyfile_offset = 0;
+static uint64_t arg_keyfile_offset = 0;
static char *arg_hash = NULL;
static char *arg_header = NULL;
static unsigned arg_tries = 3;
@@ -131,13 +131,22 @@ static int parse_one_option(const char *option) {
}
} else if ((val = startswith(option, "keyfile-offset="))) {
+ uint64_t off;
- r = safe_atou(val, &arg_keyfile_offset);
+ r = safe_atou64(val, &off);
if (r < 0) {
log_error_errno(r, "Failed to parse %s, ignoring: %m", option);
return 0;
}
+ if ((size_t) off != off) {
+ /* https://gitlab.com/cryptsetup/cryptsetup/issues/359 */
+ log_error("keyfile-offset= value would truncated to %zu, ignoring.", (size_t) off);
+ return 0;
+ }
+
+ arg_keyfile_offset = off;
+
} else if ((val = startswith(option, "hash="))) {
r = free_and_strdup(&arg_hash, val);
if (r < 0)