[PATCH] Don't let XFD_SETSIZE exceed FD_SETSIZE
James Clarke
jrtc27 at jrtc27.com
Sun Apr 24 11:36:10 UTC 2016
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.
---
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
--
2.8.1
More information about the xorg-devel
mailing list