summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2023-06-22 18:33:53 +0200
committerjvoisin2023-06-22 18:33:53 +0200
commit28d61f4202a73fa39d07774c66e1404858adfee9 (patch)
treec90033e7720c64296c036f52cc2da84f796c361d
parent79447cbb8dc30e2335e3bb186de8e1172b3dff90 (diff)
Add a test for `poll`
-rw-r--r--include/poll.h4
-rw-r--r--tests/Makefile1
-rw-r--r--tests/test_poll.c14
3 files changed, 17 insertions, 2 deletions
diff --git a/include/poll.h b/include/poll.h
index a50a0d6..0500ab4 100644
--- a/include/poll.h
+++ b/include/poll.h
@@ -32,7 +32,7 @@ extern "C" {
32 32
33_FORTIFY_FN(poll) int poll(struct pollfd *__f, nfds_t __n, int __s) 33_FORTIFY_FN(poll) int poll(struct pollfd *__f, nfds_t __n, int __s)
34{ 34{
35 __typeof__(sizeof 0) __b = __bos(__f, 0); 35 size_t __b = __bos(__f, 0);
36 36
37 if (__n > __b / sizeof(struct pollfd)) 37 if (__n > __b / sizeof(struct pollfd))
38 __builtin_trap(); 38 __builtin_trap();
@@ -44,7 +44,7 @@ _FORTIFY_FN(poll) int poll(struct pollfd *__f, nfds_t __n, int __s)
44_FORTIFY_FN(ppoll) int ppoll(struct pollfd *__f, nfds_t __n, const struct timespec *__s, 44_FORTIFY_FN(ppoll) int ppoll(struct pollfd *__f, nfds_t __n, const struct timespec *__s,
45 const sigset_t *__m) 45 const sigset_t *__m)
46{ 46{
47 __typeof__(sizeof 0) __b = __bos(__f, 0); 47 size_t __b = __bos(__f, 0);
48 48
49 if (__n > __b / sizeof(struct pollfd)) 49 if (__n > __b / sizeof(struct pollfd))
50 __builtin_trap(); 50 __builtin_trap();
diff --git a/tests/Makefile b/tests/Makefile
index b27b294..fa0bcdd 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -31,6 +31,7 @@ TARGETS=test_memcpy_static_write \
31 test_stpncpy_overwrite_under \ 31 test_stpncpy_overwrite_under \
32 test_stpncpy_static_write \ 32 test_stpncpy_static_write \
33 test_getcwd \ 33 test_getcwd \
34 test_poll \
34 35
35.SILENT: 36.SILENT:
36 37
diff --git a/tests/test_poll.c b/tests/test_poll.c
new file mode 100644
index 0000000..397aa3d
--- /dev/null
+++ b/tests/test_poll.c
@@ -0,0 +1,14 @@
1#include "common.h"
2
3#include <poll.h>
4
5int main(int argc, char** argv) {
6 struct pollfd buffer[12] = {0};
7
8 CHK_FAIL_START
9 poll(buffer, 14, NULL);
10 CHK_FAIL_END
11
12 puts(buffer);
13 return ret;
14}