]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-daemon: use path_join() instead of manual path concat 22508/head
authorLennart Poettering <lennart@poettering.net>
Mon, 14 Feb 2022 16:23:35 +0000 (17:23 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 14 Feb 2022 16:27:24 +0000 (17:27 +0100)
src/libsystemd/sd-daemon/sd-daemon.c

index b5f62ec5e871d17b4e75b092903836c125faba6d..4987eab916435d7535b136fdc42083b055bde3b7 100644 (file)
@@ -412,7 +412,7 @@ _public_ int sd_is_mq(int fd, const char *path) {
         }
 
         if (path) {
-                char fpath[PATH_MAX];
+                _cleanup_free_ char *fpath = NULL;
                 struct stat a, b;
 
                 assert_return(path_is_absolute(path), -EINVAL);
@@ -420,8 +420,9 @@ _public_ int sd_is_mq(int fd, const char *path) {
                 if (fstat(fd, &a) < 0)
                         return -errno;
 
-                strncpy(stpcpy(fpath, "/dev/mqueue"), path, sizeof(fpath) - 12);
-                fpath[sizeof(fpath)-1] = 0;
+                fpath = path_join("/dev/mqueue", path);
+                if (!fpath)
+                        return -ENOMEM;
 
                 if (stat(fpath, &b) < 0)
                         return -errno;