1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 19:23:13 +02:00

core: fix crash if a file descriptor used in hook_fd() is too high (> 1024 on Linux/BSD) (closes #465)

The calls to select() are replaced by poll(), which doesn't have limitation
on file descriptor number.
This commit is contained in:
Sébastien Helleu
2015-07-18 20:03:34 +02:00
parent 23983b125a
commit 3b2ee85b04
9 changed files with 182 additions and 132 deletions
+8 -5
View File
@@ -39,7 +39,7 @@
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <poll.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
@@ -611,7 +611,7 @@ network_pass_proxy (const char *proxy, int sock, const char *address, int port)
int
network_connect (int sock, const struct sockaddr *addr, socklen_t addrlen)
{
fd_set write_fds;
struct pollfd poll_fd;
int ready, value;
socklen_t len;
@@ -628,9 +628,12 @@ network_connect (int sock, const struct sockaddr *addr, socklen_t addrlen)
*/
while (1)
{
FD_ZERO (&write_fds);
FD_SET (sock, &write_fds);
ready = select (sock + 1, NULL, &write_fds, NULL, NULL);
poll_fd.fd = sock;
poll_fd.events = POLLOUT;
poll_fd.revents = 0;
ready = poll (&poll_fd, 1, -1);
if (ready < 0)
break;
if (ready > 0)
{
len = sizeof (value);