0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-26 23:01:04 +08:00

Problem: EFAULT is returned for bad file descriptors passed to zmq_poller_*_fd

Solution: Return EBADF instead
This commit is contained in:
sigiesec 2017-08-22 18:44:57 +02:00
parent 74303b08e6
commit 6a3c053a3e
2 changed files with 6 additions and 6 deletions

View File

@ -1270,7 +1270,7 @@ int zmq_poller_add_fd (void *poller_, int fd_, void *user_data_, short events_)
return -1;
}
if (fd_ == zmq::retired_fd) {
errno = ENOTSOCK;
errno = EBADF;
return -1;
}
@ -1306,7 +1306,7 @@ int zmq_poller_modify_fd (void *poller_, int fd_, short events_)
return -1;
}
if (fd_ == zmq::retired_fd) {
errno = ENOTSOCK;
errno = EBADF;
return -1;
}
@ -1341,7 +1341,7 @@ int zmq_poller_remove_fd (void *poller_, int fd_)
return -1;
}
if (fd_ == zmq::retired_fd) {
errno = ENOTSOCK;
errno = EBADF;
return -1;
}

View File

@ -121,13 +121,13 @@ void test_null_socket_pointers ()
fd_t null_socket_fd = retired_fd;
rc = zmq_poller_add_fd (poller, null_socket_fd, NULL, ZMQ_POLLIN);
assert (rc == -1 && errno == ENOTSOCK);
assert (rc == -1 && errno == EBADF);
rc = zmq_poller_modify_fd (poller, null_socket_fd, ZMQ_POLLIN);
assert (rc == -1 && errno == ENOTSOCK);
assert (rc == -1 && errno == EBADF);
rc = zmq_poller_remove_fd (poller, null_socket_fd);
assert (rc == -1 && errno == ENOTSOCK);
assert (rc == -1 && errno == EBADF);
rc = zmq_poller_destroy (&poller);
assert (rc == 0);