From: Mike Yuan Date: Mon, 10 Feb 2025 18:04:29 +0000 (+0100) Subject: env-util: use strextendn() instead of strnappend() where appropriate X-Git-Tag: v258-rc1~1363^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea5fbc3938576af874486efc4a69a425f2358f3e;p=thirdparty%2Fsystemd.git env-util: use strextendn() instead of strnappend() where appropriate --- diff --git a/src/basic/env-util.c b/src/basic/env-util.c index 99ce1a18420..09c8e7c28f8 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -695,7 +695,7 @@ int replace_env_full( _cleanup_strv_free_ char **unset_variables = NULL, **bad_variables = NULL; const char *e, *word = format, *test_value = NULL; /* test_value is initialized to appease gcc */ _cleanup_free_ char *s = NULL; - char ***pu, ***pb, *k; + char ***pu, ***pb; size_t i, len = 0; /* len is initialized to appease gcc */ int nest = 0, r; @@ -717,33 +717,24 @@ int replace_env_full( case CURLY: if (*e == '{') { - k = strnappend(s, word, e-word-1); - if (!k) + if (!strextendn(&s, word, e-word-1)) return -ENOMEM; - free_and_replace(s, k); - word = e-1; state = VARIABLE; nest++; } else if (*e == '$') { - k = strnappend(s, word, e-word); - if (!k) + if (!strextendn(&s, word, e-word)) return -ENOMEM; - free_and_replace(s, k); - word = e+1; state = WORD; } else if (FLAGS_SET(flags, REPLACE_ENV_ALLOW_BRACELESS) && strchr(VALID_BASH_ENV_NAME_CHARS, *e)) { - k = strnappend(s, word, e-word-1); - if (!k) + if (!strextendn(&s, word, e-word-1)) return -ENOMEM; - free_and_replace(s, k); - word = e-1; state = VARIABLE_RAW;