1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

cryptsetup: don't assert on variable which is optional

50d2eba27b (commitcomment-34519739)

In add_crypttab_devices() split_keyspec is called on the keyfile argument,
which may be NULL.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-08-01 08:15:43 +02:00
parent 5d2100dc4c
commit fef716b28b

View 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;