From: Sascha Wildner Date: Mon, 18 Jun 2012 06:35:20 +0000 (+0200) Subject: cryptdisks(8): Fix a wrong sizeof. X-Git-Tag: v3.2.0~760 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/1c482147161e84edc1dbe4f1b41114b9ad16c552 cryptdisks(8): Fix a wrong sizeof. Use the size passed to the alloc_safe_mem() here. Found-with: Coccinelle (http://coccinelle.lip6.fr/) --- 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);