diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-23 10:38:07 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-23 10:38:07 -0800 |
| commit | 0421d8e9b0461c7bf9025dd736529aaf5f0fda9d (patch) | |
| tree | 1f4255cbb876d8ee5d6df7ac09cc6ce71acfd0db /src/sp/transport/socket | |
| parent | 6dfdcac062fbae3046ab81326b57599d3645705f (diff) | |
| download | nng-0421d8e9b0461c7bf9025dd736529aaf5f0fda9d.tar.gz nng-0421d8e9b0461c7bf9025dd736529aaf5f0fda9d.tar.bz2 nng-0421d8e9b0461c7bf9025dd736529aaf5f0fda9d.zip | |
socket: fds can never be negative
Diffstat (limited to 'src/sp/transport/socket')
| -rw-r--r-- | src/sp/transport/socket/sockfd_test.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sp/transport/socket/sockfd_test.c b/src/sp/transport/socket/sockfd_test.c index c27f49bd..de1f582b 100644 --- a/src/sp/transport/socket/sockfd_test.c +++ b/src/sp/transport/socket/sockfd_test.c @@ -485,6 +485,22 @@ test_sfd_fd_option_type(void) } void +test_sfd_fd_invalid_fd(void) +{ +#ifdef NNG_HAVE_SOCKETPAIR + nng_socket s; + nng_listener l; + + NUTS_OPEN(s); + NUTS_PASS(nng_listener_create(&l, s, "socket://")); + NUTS_FAIL( + nng_listener_set_int(l, NNG_OPT_SOCKET_FD, -100), NNG_EINVAL); + NUTS_CLOSE(s); +#else + NUTS_SKIP("no socketpair"); +#endif +} +void test_sfd_fd_dev_zero(void) { #ifdef NNG_HAVE_SOCKETPAIR @@ -521,6 +537,7 @@ NUTS_TESTS = { { "socket pipe peer id", test_sockfd_pipe_peer }, { "socket listen full", test_sfd_listen_full }, { "socket bad fd type", test_sfd_fd_option_type }, + { "socket invalid fd", test_sfd_fd_invalid_fd }, { "socket dev zero", test_sfd_fd_dev_zero }, { NULL, NULL }, }; |
