diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2015-07-18 19:54:59 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2015-07-18 19:54:59 +0200 |
commit | 23983b125aa37a87ee439cd9b6f7f417e8b2c079 (patch) | |
tree | fb27d7920262a99cd9e7230a17078313cb2b57ff /src/plugins | |
parent | 4da1472bc8d67af3a56483fe79e214d535a8f466 (diff) | |
download | weechat-23983b125aa37a87ee439cd9b6f7f417e8b2c079.zip |
xfer: fix crash if the DCC file socket number is too high (issue #465)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/xfer/xfer-dcc.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/plugins/xfer/xfer-dcc.c b/src/plugins/xfer/xfer-dcc.c index 64d6c8381..850585311 100644 --- a/src/plugins/xfer/xfer-dcc.c +++ b/src/plugins/xfer/xfer-dcc.c @@ -26,7 +26,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> -#include <sys/select.h> +#include <poll.h> #include <netinet/in.h> #include <fcntl.h> #include <time.h> @@ -312,7 +312,7 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer) static char buffer[XFER_BLOCKSIZE_MAX]; time_t last_sent, new_time; unsigned long long pos_last_ack; - fd_set read_fds, write_fds, except_fds; + struct pollfd poll_fd; ssize_t written, total_written; unsigned char *bin_hash; char hash[9]; @@ -362,12 +362,11 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer) while (1) { /* wait until there is something to read on socket (or error) */ - FD_ZERO (&read_fds); - FD_ZERO (&write_fds); - FD_ZERO (&except_fds); - FD_SET (xfer->sock, &read_fds); - ready = select (xfer->sock + 1, &read_fds, &write_fds, &except_fds, NULL); - if (ready == 0) + poll_fd.fd = xfer->sock; + poll_fd.events = POLLIN; + poll_fd.revents = 0; + ready = poll (&poll_fd, 1, -1); + if (ready <= 0) { xfer_network_write_pipe (xfer, XFER_STATUS_FAILED, XFER_ERROR_RECV_BLOCK); |