Commit 6a3c053a authored by sigiesec's avatar sigiesec

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

Solution: Return EBADF instead
parent 74303b08
......@@ -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;
}
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment