This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/4] tst-chk1: add fd_set dynamic allocation test


---
 ChangeLog        |    5 +++++
 debug/tst-chk1.c |   25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0ca0a47..4b80b8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,11 @@
 	* debug/tst-lfschk7.c: Likewise.
 	* debug/Makefile: Added tst-chk7.c and tst-lfschk7.c.
 
+	* debug/tst-chk1.c (do_test): Added tests for fd_set allocation
+	from heap.
+
+2013-03-29  KOSAKI Motohiro  <kosaki.motohiro@gmail.com>
+
 	* sysdeps/unix/sysv/linux/i386/nptl/libc.abilist:
 	Add __fdelt_check and __fdelt_check_warn.
 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/nptl/libc.abilist:
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index 4ca0596..54016c5 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -1451,6 +1451,7 @@ do_test (void)
 #endif
 
   fd_set s;
+  fd_set *pfdset;
   FD_ZERO (&s);
   FD_SET (FD_SETSIZE - 1, &s);
 #if __USE_FORTIFY_LEVEL >= 1 && _STRICT_FD_SIZE_CHECK >= 1
@@ -1458,18 +1459,42 @@ do_test (void)
   FD_SET (FD_SETSIZE, &s);
   CHK_FAIL_END
 #endif
+#if __USE_FORTIFY_LEVEL >= 1 && !(_STRICT_FD_SIZE_CHECK >= 1)
+  pfdset = (fd_set*)calloc(howmany(FD_SETSIZE+1, NFDBITS), sizeof(fd_mask));
+  if (pfdset == NULL) {
+    printf("malloc failed %m\n");
+    return 1;
+  }
+  FD_SET (FD_SETSIZE, pfdset);
+#endif
   FD_CLR (FD_SETSIZE - 1, &s);
 #if __USE_FORTIFY_LEVEL >= 1 && _STRICT_FD_SIZE_CHECK >= 1
   CHK_FAIL_START
   FD_CLR (FD_SETSIZE, &s);
   CHK_FAIL_END
 #endif
+#if __USE_FORTIFY_LEVEL >= 1 && !(_STRICT_FD_SIZE_CHECK >= 1)
+  pfdset = (fd_set*)calloc(howmany(FD_SETSIZE+1, NFDBITS), sizeof(fd_mask));
+  if (pfdset == NULL) {
+    printf("malloc failed %m\n");
+    return 1;
+  }
+  FD_CLR (FD_SETSIZE, pfdset);
+#endif
   FD_ISSET (FD_SETSIZE - 1, &s);
 #if __USE_FORTIFY_LEVEL >= 1 && _STRICT_FD_SIZE_CHECK >= 1
   CHK_FAIL_START
   FD_ISSET (FD_SETSIZE, &s);
   CHK_FAIL_END
 #endif
+#if __USE_FORTIFY_LEVEL >= 1 && !(_STRICT_FD_SIZE_CHECK >= 1)
+  pfdset = (fd_set*)calloc(howmany(FD_SETSIZE+1, NFDBITS), sizeof(fd_mask));
+  if (pfdset == NULL) {
+    printf("malloc failed %m\n");
+    return 1;
+  }
+  FD_ISSET (FD_SETSIZE, pfdset);
+#endif
 
   struct pollfd fds[1];
   fds[0].fd = STDOUT_FILENO;
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]