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
This commit is contained in:
Lennart Poettering 2017-12-27 12:43:31 +01:00 committed by GitHub
parent 559fdfa3e5
commit d31eb24fc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 6 deletions

View File

@ -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"