From: Masatake YAMATO Date: Sun, 5 Apr 2026 20:45:53 +0000 (+0900) Subject: lsfd: ignore too large integer read from /proc/PID/syscall X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=259e5fca7bd015b55e25f7908dde76e49f0f3aa9;p=thirdparty%2Futil-linux.git lsfd: ignore too large integer read from /proc/PID/syscall Fixes #4168 Signed-off-by: Masatake YAMATO --- diff --git a/lsfd-cmd/lsfd.c b/lsfd-cmd/lsfd.c index ca4c91b9a..162780fec 100644 --- a/lsfd-cmd/lsfd.c +++ b/lsfd-cmd/lsfd.c @@ -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;