Skip to content

Commit

Permalink
Add a test for poll
Browse files Browse the repository at this point in the history
  • Loading branch information
jvoisin committed Jun 22, 2023
1 parent 79447cb commit 28d61f4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern "C" {

_FORTIFY_FN(poll) int poll(struct pollfd *__f, nfds_t __n, int __s)
{
__typeof__(sizeof 0) __b = __bos(__f, 0);
size_t __b = __bos(__f, 0);

if (__n > __b / sizeof(struct pollfd))
__builtin_trap();
Expand All @@ -44,7 +44,7 @@ _FORTIFY_FN(poll) int poll(struct pollfd *__f, nfds_t __n, int __s)
_FORTIFY_FN(ppoll) int ppoll(struct pollfd *__f, nfds_t __n, const struct timespec *__s,
const sigset_t *__m)
{
__typeof__(sizeof 0) __b = __bos(__f, 0);
size_t __b = __bos(__f, 0);

if (__n > __b / sizeof(struct pollfd))
__builtin_trap();
Expand Down
1 change: 1 addition & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ TARGETS=test_memcpy_static_write \
test_stpncpy_overwrite_under \
test_stpncpy_static_write \
test_getcwd \
test_poll \

.SILENT:

Expand Down
14 changes: 14 additions & 0 deletions tests/test_poll.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "common.h"

#include <poll.h>

int main(int argc, char** argv) {
struct pollfd buffer[12] = {0};

CHK_FAIL_START
poll(buffer, 14, NULL);
CHK_FAIL_END

puts(buffer);
return ret;
}

0 comments on commit 28d61f4

Please sign in to comment.