]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: do not obscure return code when checking verity options
authorLuca Boccassi <luca.boccassi@microsoft.com>
Tue, 7 Jan 2020 20:29:57 +0000 (20:29 +0000)
committerKarel Zak <kzak@redhat.com>
Wed, 8 Jan 2020 11:59:23 +0000 (12:59 +0100)
In some corner cases, the return code was being overwritten without
being checked

libmount/src/context_veritydev.c

index 2ef437642c7048c7bfb0ec2bdb3f2c59143109f8..fd5662ce56207b26b174e23a7b9660166f770b61 100644 (file)
@@ -153,15 +153,15 @@ int mnt_context_setup_veritydev(struct libmnt_context *cxt)
                }
        }
 
-       if (root_hash && root_hash_file) {
+       if (!rc && root_hash && root_hash_file) {
                DBG(VERITY, ul_debugobj(cxt, "verity.roothash and verity.roothashfile are mutually exclusive"));
                rc = -EINVAL;
-       } else if (root_hash_file) {
+       } else if (!rc && root_hash_file) {
                rc = ul_path_read_string(NULL, &root_hash, root_hash_file);
                rc = rc < 1 ? rc : 0;
        }
 
-       if (!hash_device || !root_hash) {
+       if (!rc && (!hash_device || !root_hash)) {
                DBG(VERITY, ul_debugobj(cxt, "verity.hashdevice and one of verity.roothash or verity.roothashfile are mandatory"));
                rc = -EINVAL;
        }