anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0300-cryptsetup-don-t-assert-on-variable-which-is-optiona.patch

b9a53a
From 5cdb2b0b2a0f8f89f97053b0633b8419506d4e28 Mon Sep 17 00:00:00 2001
b9a53a
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
b9a53a
Date: Thu, 1 Aug 2019 08:15:43 +0200
b9a53a
Subject: [PATCH] cryptsetup: don't assert on variable which is optional
b9a53a
b9a53a
https://github.com/systemd/systemd/commit/50d2eba27b9bfc77ef6b40e5721713846815418b#commitcomment-34519739
b9a53a
b9a53a
In add_crypttab_devices() split_keyspec is called on the keyfile argument,
b9a53a
which may be NULL.
b9a53a
b9a53a
(cherry picked from commit fef716b28be6e866b8afe995805d5ebe2af6bbfa)
b9a53a
b9a53a
Related: #1763155
b9a53a
---
b9a53a
 src/cryptsetup/cryptsetup-generator.c | 6 +++++-
b9a53a
 1 file changed, 5 insertions(+), 1 deletion(-)
b9a53a
b9a53a
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
b9a53a
index 7b234e37be..a09983b576 100644
b9a53a
--- a/src/cryptsetup/cryptsetup-generator.c
b9a53a
+++ b/src/cryptsetup/cryptsetup-generator.c
b9a53a
@@ -44,10 +44,14 @@ static int split_keyspec(const char *keyspec, char **ret_keyfile, char **ret_key
b9a53a
         _cleanup_free_ char *keyfile = NULL, *keydev = NULL;
b9a53a
         const char *c;
b9a53a
 
b9a53a
-        assert(keyspec);
b9a53a
         assert(ret_keyfile);
b9a53a
         assert(ret_keydev);
b9a53a
 
b9a53a
+        if (!keyspec) {
b9a53a
+                *ret_keyfile = *ret_keydev = NULL;
b9a53a
+                return 0;
b9a53a
+        }
b9a53a
+
b9a53a
         c = strrchr(keyspec, ':');
b9a53a
         if (c) {
b9a53a
                 keyfile = strndup(keyspec, c-keyspec);