Proper handle error in device block get.
authorMilan Broz <gmazyland@gmail.com>
Tue, 28 Aug 2012 11:30:17 +0000 (13:30 +0200)
committerMilan Broz <gmazyland@gmail.com>
Tue, 28 Aug 2012 11:30:17 +0000 (13:30 +0200)
lib/luks1/keyencryption.c

index cfc0f10..84303ea 100644 (file)
@@ -110,9 +110,12 @@ static int LUKS_endec_template(char *src, size_t srcLength,
        int r = -1;
        int bsize = device_block_size(crypt_metadata_device(ctx));
 
+       if (bsize <= 0)
+               return -EINVAL;
+
        if(dmDir == NULL) {
                log_err(ctx, _("Failed to obtain device mapper directory."));
-               return -1;
+               return -EINVAL;
        }
        if(asprintf(&name,"temporary-cryptsetup-%d",getpid())               == -1 ||
           asprintf(&fullpath,"%s/%s",dmDir,name)                           == -1 ||