cryptdisks - Add retval checks for popen and alloc
authorAlex Hornung <ahornung@gmail.com>
Fri, 17 Jun 2011 23:05:57 +0000 (00:05 +0100)
committerAlex Hornung <ahornung@gmail.com>
Fri, 17 Jun 2011 23:05:57 +0000 (00:05 +0100)
sbin/cryptdisks/cryptdisks.c

index b778218..58ab16b 100644 (file)
@@ -222,8 +222,15 @@ parse_crypt_options(struct crypt_options *co, char *option)
 
                /* Allocate safe key memory */
                buf = alloc_safe_mem(8192);
+               if (buf == NULL)
+                       err(1, "Could not allocate safe memory");
+                       /* NOTREACHED */
 
                fd = popen(parameter, "r");
+               if (fd == NULL)
+                       syntax_error("The 'keyscript' file could not be run");
+                       /* NOTREACHED */
+
                if ((fread(buf, 1, sizeof(buf), fd)) == 0)
                        syntax_error("The 'keyscript' program failed");
                        /* NOTREACHED */