diff options
-rw-r--r-- | ChangeLog.asciidoc | 2 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-dcc.c | 15 |
2 files changed, 9 insertions, 8 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index 25154109c..ae5315c33 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -33,6 +33,8 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] (closes #440) * script: rename option script.scripts.dir to script.scripts.path, evaluate content of option (issue #388) +* xfer: fix crash if the DCC file socket number is too high + (> 1024 on Linux/BSD) (issue #465) * xfer: evaluate content of options xfer.file.download_path and xfer.file.upload_path (issue #388) 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); |