From 1c482147161e84edc1dbe4f1b41114b9ad16c552 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Mon, 18 Jun 2012 08:35:20 +0200 Subject: [PATCH] cryptdisks(8): Fix a wrong sizeof. Use the size passed to the alloc_safe_mem() here. Found-with: Coccinelle (http://coccinelle.lip6.fr/) --- sbin/cryptdisks/cryptdisks.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sbin/cryptdisks/cryptdisks.c b/sbin/cryptdisks/cryptdisks.c index b20d274182..5f7d9f5b3a 100644 --- a/sbin/cryptdisks/cryptdisks.c +++ b/sbin/cryptdisks/cryptdisks.c @@ -227,12 +227,14 @@ parse_crypt_options(struct generic_opts *go, char *option) go->timeout = ullval; } else if (strcmp(option, "keyscript") == 0) { + size_t keymem_len = 8192; + if (noparam) syntax_error("The option 'keyscript' needs a parameter"); /* NOTREACHED */ /* Allocate safe key memory */ - buf = alloc_safe_mem(8192); + buf = alloc_safe_mem(keymem_len); if (buf == NULL) err(1, "Could not allocate safe memory"); /* NOTREACHED */ @@ -242,7 +244,7 @@ parse_crypt_options(struct generic_opts *go, char *option) syntax_error("The 'keyscript' file could not be run"); /* NOTREACHED */ - if ((fread(buf, 1, sizeof(buf), fd)) == 0) + if ((fread(buf, 1, keymem_len, fd)) == 0) syntax_error("The 'keyscript' program failed"); /* NOTREACHED */ pclose(fd); -- 2.41.0