diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-07-09 15:29:47 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-07-09 15:29:47 +0200 |
commit | d1829af943d0d47c745c3ce789690493e7b8107a (patch) | |
tree | 5b929eaa72a9303328c54622fb390d5f124ded1e /src | |
parent | 89fa9a6b7b2505aa2ce18febf1e28e79510dfec2 (diff) | |
download | systemd-d1829af943d0d47c745c3ce789690493e7b8107a.tar.gz |
creds: fix leak of arg_tpm2_device
IIUC, "auto" is the same as NULL. There is no need to strdup() anything.
Coverity CID#1458113.
Diffstat (limited to 'src')
-rw-r--r-- | src/creds/creds.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/creds/creds.c b/src/creds/creds.c index 19893fb361..95d5bf0cfa 100644 --- a/src/creds/creds.c +++ b/src/creds/creds.c @@ -704,30 +704,20 @@ static int parse_argv(int argc, char *argv[]) { arg_with_key = CRED_AES256_GCM_BY_TPM2_HMAC; break; - case ARG_TPM2_DEVICE: { - _cleanup_free_ char *device = NULL; - + case ARG_TPM2_DEVICE: if (streq(optarg, "list")) return tpm2_list_devices(); - if (!streq(optarg, "auto")) { - device = strdup(optarg); - if (!device) - return log_oom(); - } - - arg_tpm2_device = TAKE_PTR(device); + arg_tpm2_device = streq(optarg, "auto") ? NULL : optarg; break; - } - - case ARG_TPM2_PCRS: { - uint32_t mask; + case ARG_TPM2_PCRS: if (isempty(optarg)) { arg_tpm2_pcr_mask = 0; break; } + uint32_t mask; r = tpm2_parse_pcrs(optarg, &mask); if (r < 0) return r; @@ -738,7 +728,6 @@ static int parse_argv(int argc, char *argv[]) { arg_tpm2_pcr_mask |= mask; break; - } case ARG_NAME: if (isempty(optarg)) { |