diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-12-27 12:43:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-27 12:43:31 +0100 |
commit | d31eb24fc2dfbafa346c8cf3ab113f790cef4f0f (patch) | |
tree | 049da2cbec1e7785b9979b28cb075571b3a8f02a /src/cryptsetup | |
parent | Merge pull request #7629 from poettering/condition-kernel-version (diff) | |
download | systemd-d31eb24fc2dfbafa346c8cf3ab113f790cef4f0f.tar.xz systemd-d31eb24fc2dfbafa346c8cf3ab113f790cef4f0f.zip |
cryptsetup: small if check improvement (#7747)
It's a bit weird to test these strings after the fact instead of before.
Let's make sure that we don't even attempt the string escaping if the
strings are NULL.
Follow-up for #7688
Diffstat (limited to 'src/cryptsetup')
-rw-r--r-- | src/cryptsetup/cryptsetup-generator.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index b41faed6ad..0b46e2db2a 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -106,9 +106,11 @@ static int create_disk( if (r < 0) return log_error_errno(r, "Failed to generate unit name: %m"); - password_escaped = specifier_escape(password); - if (password && !password_escaped) - return log_oom(); + if (password) { + password_escaped = specifier_escape(password); + if (!password_escaped) + return log_oom(); + } r = generator_open_unit_file(arg_dest, NULL, n, &f); if (r < 0) @@ -176,9 +178,11 @@ static int create_disk( if (r < 0) return r; - filtered_escaped = specifier_escape(filtered); - if (filtered && !filtered_escaped) - return log_oom(); + if (filtered) { + filtered_escaped = specifier_escape(filtered); + if (!filtered_escaped) + return log_oom(); + } fprintf(f, "\n[Service]\n" |