From: Mike Yuan Date: Mon, 10 Feb 2025 18:04:08 +0000 (+0100) Subject: cryptsetup: port to strprepend() X-Git-Tag: v258-rc1~1363^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ce0a5106678b49fc67a9650c433f58781e3a0f1f;p=thirdparty%2Fsystemd.git cryptsetup: port to strprepend() --- 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') */