]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
seccomp: convert to strnprintf()
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 11 Feb 2021 09:46:47 +0000 (10:46 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 11 Feb 2021 09:46:47 +0000 (10:46 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/seccomp.c

index 72cbb530ade52dab530682f99c2d648c11fbaab6..4e4180385a6e1528049ca5868f6b44dc89c2c083 100644 (file)
@@ -1418,7 +1418,13 @@ int seccomp_notify_handler(int fd, uint32_t events, void *data,
        resp->id = req_id = req->id;
        TRACE("Received seccomp notification with id(%llu)", (long long unsigned int)req_id);
 
-       snprintf(mem_path, sizeof(mem_path), "/proc/%d", req->pid);
+       ret = strnprintf(mem_path, sizeof(mem_path), "/proc/%d", req->pid);
+       if (ret < 0) {
+               seccomp_notify_default_answer(fd, req, resp, hdlr);
+               SYSERROR("Failed to create path to process's proc directory");
+               goto out;
+       }
+
        fd_pid = open(mem_path, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
        if (fd_pid < 0) {
                seccomp_notify_default_answer(fd, req, resp, hdlr);
@@ -1426,7 +1432,13 @@ int seccomp_notify_handler(int fd, uint32_t events, void *data,
                goto out;
        }
 
-       snprintf(mem_path, sizeof(mem_path), "/proc/%d/mem", req->pid);
+       ret = strnprintf(mem_path, sizeof(mem_path), "/proc/%d/mem", req->pid);
+       if (ret < 0) {
+               seccomp_notify_default_answer(fd, req, resp, hdlr);
+               SYSERROR("Failed to create path to process's virtual memory");
+               goto out;
+       }
+
        fd_mem = open(mem_path, O_RDWR | O_CLOEXEC);
        if (fd_mem < 0) {
                seccomp_notify_default_answer(fd, req, resp, hdlr);