]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptsetup: don't assert on variable which is optional 13243/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 1 Aug 2019 06:15:43 +0000 (08:15 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 1 Aug 2019 07:49:24 +0000 (09:49 +0200)
https://github.com/systemd/systemd/commit/50d2eba27b9bfc77ef6b40e5721713846815418b#commitcomment-34519739

In add_crypttab_devices() split_keyspec is called on the keyfile argument,
which may be NULL.

src/cryptsetup/cryptsetup-generator.c

index 84483143945755688cdbec346f256d74431abcb0..4815ded753fae1f8660bf6a7d5643ed12631861a 100644 (file)
@@ -50,10 +50,14 @@ static int split_keyspec(const char *keyspec, char **ret_keyfile, char **ret_key
         _cleanup_free_ char *keyfile = NULL, *keydev = NULL;
         const char *c;
 
-        assert(keyspec);
         assert(ret_keyfile);
         assert(ret_keydev);
 
+        if (!keyspec) {
+                *ret_keyfile = *ret_keydev = NULL;
+                return 0;
+        }
+
         c = strrchr(keyspec, ':');
         if (c) {
                 keyfile = strndup(keyspec, c-keyspec);
@@ -567,7 +571,7 @@ static int add_crypttab_devices(void) {
         }
 
         for (;;) {
-                _cleanup_free_ char *line = NULL, *name = NULL, *device = NULL, *keydev = NULL, *keyfile = NULL, *keyspec = NULL, *options = NULL;
+                _cleanup_free_ char *line = NULL, *name = NULL, *device = NULL, *keyspec = NULL, *options = NULL, *keyfile = NULL, *keydev = NULL;
                 crypto_device *d = NULL;
                 char *l, *uuid;
                 int k;