From ce0a5106678b49fc67a9650c433f58781e3a0f1f Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Mon, 10 Feb 2025 19:04:08 +0100 Subject: [PATCH] cryptsetup: port to strprepend() --- src/cryptsetup/cryptsetup.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 6fd10613d14..d109d0914ff 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -600,14 +600,15 @@ static int parse_one_option(const char *option) { * - text descriptions prefixed with "%:" or "%keyring:". * - text description with no prefix. * - numeric keyring id (ignored in current patch set). */ - if (IN_SET(*val, '@', '%')) - keyring = strndup(val, sep - val); - else - /* add type prefix if missing (crypt_set_keyring_to_link() expects it) */ - keyring = strnappend("%:", val, sep - val); + keyring = strndup(val, sep - val); if (!keyring) return log_oom(); + /* add type prefix if missing (crypt_set_keyring_to_link() expects it) */ + if (!IN_SET(*keyring, '@', '%')) + if (!strprepend(&keyring, "%:")) + return log_oom(); + sep += 2; /* % is optional (and defaults to 'user') */ -- 2.47.3