summaryrefslogtreecommitdiffstats
path: root/src/shared/dropin.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
commitfc53809803cd2bc2434e312b19a18fa36776da12 (patch)
treeb4b43bd6538f51965ce32856e9c053d0f90919c8 /src/shared/dropin.c
parentAdding upstream version 255.5. (diff)
downloadsystemd-fc53809803cd2bc2434e312b19a18fa36776da12.tar.xz
systemd-fc53809803cd2bc2434e312b19a18fa36776da12.zip
Adding upstream version 256.upstream/256
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/shared/dropin.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/shared/dropin.c b/src/shared/dropin.c
index d46e838..9a786d0 100644
--- a/src/shared/dropin.c
+++ b/src/shared/dropin.c
@@ -26,7 +26,7 @@
int drop_in_file(const char *dir, const char *unit, unsigned level,
const char *name, char **ret_p, char **ret_q) {
- char prefix[DECIMAL_STR_MAX(unsigned)];
+ char prefix[DECIMAL_STR_MAX(unsigned) + 1] = {};
_cleanup_free_ char *b = NULL, *p = NULL, *q = NULL;
assert(unit);
@@ -34,7 +34,8 @@ int drop_in_file(const char *dir, const char *unit, unsigned level,
assert(ret_p);
assert(ret_q);
- sprintf(prefix, "%u", level);
+ if (level != UINT_MAX)
+ xsprintf(prefix, "%u-", level);
b = xescape(name, "/.");
if (!b)
@@ -44,7 +45,7 @@ int drop_in_file(const char *dir, const char *unit, unsigned level,
return -EINVAL;
p = strjoin(dir, "/", unit, ".d");
- q = strjoin(p, "/", prefix, "-", b, ".conf");
+ q = strjoin(p, "/", prefix, b, ".conf");
if (!p || !q)
return -ENOMEM;