1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 01:03:14 +02:00

core: fix freeze when hook_fd is called with a bad file/socket (bug #33619)

This commit is contained in:
Sebastien Helleu
2011-06-22 12:20:05 +02:00
parent ebac36d075
commit 6defc05f0a
2 changed files with 24 additions and 16 deletions
+1
View File
@@ -7,6 +7,7 @@ v0.3.6-dev, 2011-06-22
Version 0.3.6 (under dev!)
--------------------------
* core: fix freeze when hook_fd is called with a bad file/socket (bug #33619)
* core: fix bug with option weechat.look.hotlist_count_max (value+1 was used)
* core: add local variable "highlight_regex" in buffers
* core: add "hdata" (direct access to WeeChat/plugin data)
+23 -16
View File
@@ -34,6 +34,8 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>
#include "weechat.h"
#include "wee-hook.h"
@@ -1221,23 +1223,28 @@ hook_fd_set (fd_set *read_fds, fd_set *write_fds, fd_set *exception_fds)
{
if (!ptr_hook->deleted)
{
if (HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_READ)
/* skip invalid file descriptors */
if ((fcntl (HOOK_FD(ptr_hook,fd), F_GETFD) != -1)
|| (errno != EBADF))
{
FD_SET (HOOK_FD(ptr_hook, fd), read_fds);
if (HOOK_FD(ptr_hook, fd) > max_fd)
max_fd = HOOK_FD(ptr_hook, fd);
}
if (HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_WRITE)
{
FD_SET (HOOK_FD(ptr_hook, fd), write_fds);
if (HOOK_FD(ptr_hook, fd) > max_fd)
max_fd = HOOK_FD(ptr_hook, fd);
}
if (HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_EXCEPTION)
{
FD_SET (HOOK_FD(ptr_hook, fd), exception_fds);
if (HOOK_FD(ptr_hook, fd) > max_fd)
max_fd = HOOK_FD(ptr_hook, fd);
if (HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_READ)
{
FD_SET (HOOK_FD(ptr_hook, fd), read_fds);
if (HOOK_FD(ptr_hook, fd) > max_fd)
max_fd = HOOK_FD(ptr_hook, fd);
}
if (HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_WRITE)
{
FD_SET (HOOK_FD(ptr_hook, fd), write_fds);
if (HOOK_FD(ptr_hook, fd) > max_fd)
max_fd = HOOK_FD(ptr_hook, fd);
}
if (HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_EXCEPTION)
{
FD_SET (HOOK_FD(ptr_hook, fd), exception_fds);
if (HOOK_FD(ptr_hook, fd) > max_fd)
max_fd = HOOK_FD(ptr_hook, fd);
}
}
}
}