util: close excessive file descriptors in iobuf_recv_from_fd

Unceremoneously close any fds that the client gives us that exceed our
expectations (which right now is a max of 32 for a protocol-valid max
of... 1).

Assisted-by: Claude:claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/388>
This commit is contained in:
Peter Hutterer 2026-04-17 18:49:12 +10:00 committed by Marge Bot
parent f63b44d8ae
commit 80e2b4e4d9

View file

@ -390,6 +390,12 @@ iobuf_recv_from_fd(struct iobuf *buf, int fd)
fd++;
}
}
/* Close any remaining fds that didn't fit in the buffer
* to prevent fd leaks */
while (*fd != -1) {
xclose(*fd);
fd++;
}
}
nread += rc;