From de30673937e2d36b84cf50c3eb05bbf9836fabfb Mon Sep 17 00:00:00 2001 From: James Clarke Date: Mon, 25 Apr 2016 17:12:08 +0100 Subject: Don't let XFD_SETSIZE exceed FD_SETSIZE This fixes 2c94cdb453bc641246cc8b9a876da9799bee1ce7 on the Hurd, as FD_SETSIZE is only 256, and so anyone using XFD_SETSIZE to iterate over the contents of an fd_set will overrun the array. Signed-off-by: James Clarke Reviewed-by: Julien Cristau --- Xpoll.h.in | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Xpoll.h.in b/Xpoll.h.in index 2878591..9f127e1 100644 --- a/Xpoll.h.in +++ b/Xpoll.h.in @@ -67,10 +67,13 @@ typedef long fd_mask; # endif #endif -#define XFD_SETSIZE 512 - -#ifndef FD_SETSIZE -#define FD_SETSIZE XFD_SETSIZE +#if defined(FD_SETSIZE) && FD_SETSIZE < 512 +# define XFD_SETSIZE FD_SETSIZE +#else +# define XFD_SETSIZE 512 +# ifndef FD_SETSIZE +# define FD_SETSIZE XFD_SETSIZE +# endif #endif #ifndef NBBY -- cgit v1.2.3