cryptdisks(8): Fix a wrong sizeof.
authorSascha Wildner <saw@online.de>
Mon, 18 Jun 2012 06:35:20 +0000 (08:35 +0200)
committerSascha Wildner <saw@online.de>
Mon, 18 Jun 2012 06:35:49 +0000 (08:35 +0200)
Use the size passed to the alloc_safe_mem() here.

Found-with: Coccinelle (http://coccinelle.lip6.fr/)

sbin/cryptdisks/cryptdisks.c

index b20d274..5f7d9f5 100644 (file)
@@ -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);