Do not allow crypt_load() on already initialised context.
authorMilan Broz <gmazyland@gmail.com>
Mon, 15 Aug 2011 16:32:36 +0000 (16:32 +0000)
committerMilan Broz <gmazyland@gmail.com>
Mon, 15 Aug 2011 16:32:36 +0000 (16:32 +0000)
Signed-off-by: Ondrej Kozina <okozina@redhat.com>
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@596 36d66b0a-2a48-0410-832c-cd162a569da5

lib/setup.c

index a69a5ff..c61d066 100644 (file)
@@ -860,6 +860,11 @@ int crypt_load(struct crypt_device *cd,
        if (requested_type && !isLUKS(requested_type))
                return -EINVAL;
 
+       if (cd->type && !isLUKS(cd->type)) {
+               log_dbg("Context is already initialised to type %s", cd->type);
+               return -EINVAL;
+       }
+
        r = init_crypto(cd);
        if (r < 0)
                return r;