mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-15 10:28:09 +02:00
util: allow for a maximum of 32 fds in xsend_with_fds
Our current maximum of fds per the protocol is exactly 1 so this has no effect but might save us in the future from some naughty client. Meanwhile, this prevents us from having a variable-length array on the stack that is caller-controller. Assisted-by: Claude:claude-opus-4-6 Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/388>
This commit is contained in:
parent
1b4a0d7c1a
commit
f63b44d8ae
1 changed files with 5 additions and 0 deletions
|
|
@ -88,6 +88,11 @@ xsend_with_fd(int fd, const void *buf, size_t len, int *fds)
|
|||
if (nfds == 0)
|
||||
return xsend(fd, buf, len);
|
||||
|
||||
const size_t MAX_FDS = 32;
|
||||
if (nfds > MAX_FDS) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
char control[CMSG_SPACE(nfds * sizeof(int))];
|
||||
struct cmsghdr *header = (struct cmsghdr *)control;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue