]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: ignore too large integer read from /proc/PID/syscall
authorMasatake YAMATO <yamato@redhat.com>
Sun, 5 Apr 2026 20:45:53 +0000 (05:45 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Fri, 17 Apr 2026 21:50:06 +0000 (06:50 +0900)
Fixes #4168

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
lsfd-cmd/lsfd.c

index ca4c91b9a81844f3181f5276169c8ec45bc793bd..162780fecea6763a84a58673c5b679bec86419d1 100644 (file)
@@ -1932,6 +1932,7 @@ static void mark_poll_fds_as_multiplexed(char *buf,
 {
        long fds;
        long nfds;
+       long max_nfds;
 
        struct iovec  local;
        struct iovec  remote;
@@ -1946,8 +1947,15 @@ static void mark_poll_fds_as_multiplexed(char *buf,
                /* Unexpected value */
                return;
 
+       max_nfds = sysconf (_SC_OPEN_MAX);
+       if (max_nfds >= 0 && nfds > max_nfds)
+               return;
+
        local.iov_len = sizeof(struct pollfd) * nfds;
-       local.iov_base = xmalloc(local.iov_len);
+       local.iov_base = malloc(local.iov_len);
+       if (!local.iov_base)
+               goto out;
+
        remote.iov_len = local.iov_len;
        remote.iov_base = (void *)fds;