summaryrefslogtreecommitdiffstats
path: root/src/integritysetup/integrity-util.c
diff options
context:
space:
mode:
authorTony Asleson <tasleson@redhat.com>2021-10-27 19:00:59 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-10-28 13:54:41 +0200
commitf4ae986649d0e6faf1e7031657d1d9acab1f8399 (patch)
treea9f604430edd045c827f9eae10e3b80b3cfcd807 /src/integritysetup/integrity-util.c
parentudev: net_id: introduce predictable names for xen-netfront (diff)
downloadsystemd-f4ae986649d0e6faf1e7031657d1d9acab1f8399.tar.xz
systemd-f4ae986649d0e6faf1e7031657d1d9acab1f8399.zip
integritysetup: Check args to prevent assert
The utility function parse_integrity_options is used to both validate integritytab options or validate and return values. In the case where we are validating only and we have specific value options we will assert.
Diffstat (limited to 'src/integritysetup/integrity-util.c')
-rw-r--r--src/integritysetup/integrity-util.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/integritysetup/integrity-util.c b/src/integritysetup/integrity-util.c
index 5970a136b8..c2d2f950de 100644
--- a/src/integritysetup/integrity-util.c
+++ b/src/integritysetup/integrity-util.c
@@ -48,16 +48,20 @@ int parse_integrity_options(
if (ret_commit_time)
*ret_commit_time = tmp_commit_time;
} else if ((val = startswith(word, "data-device="))) {
- r = free_and_strdup(ret_data_device, val);
- if (r < 0)
- return log_oom();
+ if (ret_data_device) {
+ r = free_and_strdup(ret_data_device, val);
+ if (r < 0)
+ return log_oom();
+ }
} else if ((val = startswith(word, "integrity-algorithm="))) {
- r = free_and_strdup(ret_integrity_alg, val);
- if (r < 0)
- return log_oom();
- r = supported_integrity_algorithm(*ret_integrity_alg);
+ r = supported_integrity_algorithm(val);
if (r < 0)
return r;
+ if (ret_integrity_alg) {
+ r = free_and_strdup(ret_integrity_alg, val);
+ if (r < 0)
+ return log_oom();
+ }
} else
log_warning("Encountered unknown option '%s', ignoring.", word);
}