summaryrefslogtreecommitdiffstats
path: root/src/cryptsetup
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-12-27 12:43:31 +0100
committerGitHub <noreply@github.com>2017-12-27 12:43:31 +0100
commitd31eb24fc2dfbafa346c8cf3ab113f790cef4f0f (patch)
tree049da2cbec1e7785b9979b28cb075571b3a8f02a /src/cryptsetup
parentMerge pull request #7629 from poettering/condition-kernel-version (diff)
downloadsystemd-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.c16
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"