From 1505c62342e2a282fa7ab855b8d898084dddced6 Mon Sep 17 00:00:00 2001 From: Elizabeth Myers Date: Tue, 3 Apr 2018 03:17:11 -0500 Subject: socket: __poll_chk --- libgcompat/socket.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libgcompat/socket.c b/libgcompat/socket.c index 971a6ba..49da09d 100644 --- a/libgcompat/socket.c +++ b/libgcompat/socket.c @@ -39,3 +39,16 @@ ssize_t __recvfrom_chk(int fd, void *buf, size_t len, size_t buflen, int flags, return recvfrom(fd, buf, len, flags, address, address_len); } + +/** + * Checked version of poll, not in LSB but found in the wild. + * + * This checks if the size of fds is large enough to hold all the fd's claimed + * in nfds. + */ +int __poll_chk(struct pollfd *fds, nfds_t nfds, int timeout, size_t fdslen) +{ + assert((fdslen / sizeof(*fds)) < nfds); + + return poll(fds, nfds, timeout); +} -- cgit v1.2.3-70-g09d2