about summary refs log tree commit diff
path: root/debug/tst-chk1.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-09-08 19:48:47 -0400
committerUlrich Drepper <drepper@gmail.com>2011-09-08 19:48:47 -0400
commita0f33f996f7986dbf37631a4577f8565b42df29e (patch)
tree78c71a736d4bd75009abba7796f0e0aca78e47ec /debug/tst-chk1.c
parent762011fe9ffded81448be4dc50a2b27faaafe4c9 (diff)
downloadglibc-a0f33f996f7986dbf37631a4577f8565b42df29e.tar.gz
glibc-a0f33f996f7986dbf37631a4577f8565b42df29e.tar.xz
glibc-a0f33f996f7986dbf37631a4577f8565b42df29e.zip
Add range checking for FD_SET, FD_CLR, and FD_ISSET
Diffstat (limited to 'debug/tst-chk1.c')
-rw-r--r--debug/tst-chk1.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index e03f3dba6d..0ec8ab07d9 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2004,2005,2006,2007,2008,2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
 
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <wchar.h>
+#include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 
@@ -107,11 +108,11 @@ int num2 = 987654;
       FAIL ();					\
     }
 #if __USE_FORTIFY_LEVEL >= 2 && (!defined __cplusplus || defined __va_arg_pack)
-#define CHK_FAIL2_START CHK_FAIL_START
-#define CHK_FAIL2_END CHK_FAIL_END
+# define CHK_FAIL2_START CHK_FAIL_START
+# define CHK_FAIL2_END CHK_FAIL_END
 #else
-#define CHK_FAIL2_START
-#define CHK_FAIL2_END
+# define CHK_FAIL2_START
+# define CHK_FAIL2_END
 #endif
 
 static int
@@ -1448,5 +1449,26 @@ do_test (void)
   CHK_FAIL_END
 #endif
 
+  fd_set s;
+  FD_ZERO (&s);
+  FD_SET (FD_SETSIZE - 1, &s);
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  FD_SET (FD_SETSIZE, &s);
+  CHK_FAIL_END
+#endif
+  FD_CLR (FD_SETSIZE - 1, &s);
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  FD_CLR (FD_SETSIZE, &s);
+  CHK_FAIL_END
+#endif
+  FD_ISSET (FD_SETSIZE - 1, &s);
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  FD_ISSET (FD_SETSIZE, &s);
+  CHK_FAIL_END
+#endif
+
   return ret;
 }