Merge pull request #28164 from poettering/replace-env-var-fixes

pid1: warn about unset+invalid env var names when resolving ExecStart= expressions and similar
This commit is contained in:
Luca Boccassi
2023-06-28 19:40:51 +01:00
committed by GitHub
9 changed files with 360 additions and 106 deletions
+27
View File
@@ -990,6 +990,33 @@ oom:
return -ENOMEM;
}
char *strextendn(char **x, const char *s, size_t l) {
assert(x);
assert(s || l == 0);
if (l == SIZE_MAX)
l = strlen_ptr(s);
else if (l > 0)
l = strnlen(s, l); /* ignore trailing noise */
if (l > 0 || !*x) {
size_t q;
char *m;
q = strlen_ptr(*x);
m = realloc(*x, q + l + 1);
if (!m)
return NULL;
memcpy_safe(m + q, s, l);
m[q + l] = 0;
*x = m;
}
return *x;
}
char *strrep(const char *s, unsigned n) {
char *r, *p;
size_t l;