about summary refs log tree commit diff
path: root/debug
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2012-01-08 11:55:32 -0500
committerUlrich Drepper <drepper@gmail.com>2012-01-08 11:55:32 -0500
commitd9a216c037590c414e4069afde01fde84794e0d6 (patch)
tree0c4cbf65be6c1a788741977cbd383def08406a78 /debug
parent15cfed3f93f60e79508043047065f189754f8e35 (diff)
downloadglibc-d9a216c037590c414e4069afde01fde84794e0d6.tar.gz
glibc-d9a216c037590c414e4069afde01fde84794e0d6.tar.xz
glibc-d9a216c037590c414e4069afde01fde84794e0d6.zip
Add checking versions of poll and ppoll
Diffstat (limited to 'debug')
-rw-r--r--debug/Makefile2
-rw-r--r--debug/Versions3
-rw-r--r--debug/poll_chk.c29
-rw-r--r--debug/ppoll_chk.c30
-rw-r--r--debug/tst-chk1.c19
5 files changed, 81 insertions, 2 deletions
diff --git a/debug/Makefile b/debug/Makefile
index 579fce66da..dca4e97615 100644
--- a/debug/Makefile
+++ b/debug/Makefile
@@ -44,7 +44,7 @@ routines  = backtrace backtracesyms backtracesymsfd noophooks \
 	    wcstombs_chk asprintf_chk vasprintf_chk dprintf_chk \
 	    vdprintf_chk obprintf_chk \
 	    longjmp_chk ____longjmp_chk \
-	    fdelt_chk \
+	    fdelt_chk poll_chk ppoll_chk \
 	    stack_chk_fail fortify_fail \
 	    $(static-only-routines)
 static-only-routines := warning-nop stack_chk_fail_local
diff --git a/debug/Versions b/debug/Versions
index 3db4a2955f..c1722fab20 100644
--- a/debug/Versions
+++ b/debug/Versions
@@ -52,6 +52,9 @@ libc {
   GLIBC_2.15 {
     __fdelt_chk; __fdelt_warn;
   }
+  GLIBC_2.16 {
+    __poll_chk; __ppoll_chk;
+  }
   GLIBC_PRIVATE {
     __fortify_fail;
   }
diff --git a/debug/poll_chk.c b/debug/poll_chk.c
new file mode 100644
index 0000000000..df795e8ae9
--- /dev/null
+++ b/debug/poll_chk.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/poll.h>
+
+
+int
+__poll_chk (struct pollfd *fds, nfds_t nfds, int timeout, __SIZE_TYPE__ fdslen)
+{
+  if (fdslen / sizeof (*fds) < nfds)
+    __chk_fail ();
+
+  return __poll (fds, nfds, timeout);
+}
diff --git a/debug/ppoll_chk.c b/debug/ppoll_chk.c
new file mode 100644
index 0000000000..63f922321c
--- /dev/null
+++ b/debug/ppoll_chk.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/poll.h>
+
+
+int
+__ppoll_chk (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
+	     const __sigset_t *ss, __SIZE_TYPE__ fdslen)
+{
+  if (fdslen / sizeof (*fds) < nfds)
+    __chk_fail ();
+
+  return ppoll (fds, nfds, timeout, ss);
+}
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index 7f0186e706..2593ab9f18 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004,2005,2006,2007,2008,2011 Free Software Foundation, Inc.
+/* Copyright (C) 2004-2008,2011,2012 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/poll.h>
 #include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -1476,5 +1477,21 @@ do_test (void)
   CHK_FAIL_END
 #endif
 
+  struct pollfd fds[1];
+  fds[0].fd = STDOUT_FILENO;
+  fds[0].events = POLLOUT;
+  poll (fds, 1, 0);
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  poll (fds, 2, 0);
+  CHK_FAIL_END
+#endif
+  ppoll (fds, 1, NULL, NULL);
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  ppoll (fds, 2, NULL, NULL);
+  CHK_FAIL_END
+#endif
+
   return ret;
 }