From 0be9a810ed4db540045e68b653a4f128c358c306 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 22 Feb 2017 10:56:56 +0000 Subject: [PATCH] dbus: Fix writing off the end of an fd_set when testing with Valgrind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the test-bus test is run under Valgrind, its code to detect FD leaks accidentally writes off the end of the fd_set it uses, as Valgrind opens some high FDs (≥1024) for internal use. Ignore those FDs. Realistically, they are never going to be leaks — in order to have a false negative from omitting this check, D-Bus would have to allocate and not leak all the FDs up to FD_SETSIZE, and then leak the first FD over that which it allocated. D-Bus never allocates anywhere near that number of FDs concurrently. Signed-off-by: Philip Withnall https://bugs.freedesktop.org/show_bug.cgi?id=99839 --- dbus/dbus-message-util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dbus/dbus-message-util.c b/dbus/dbus-message-util.c index 9fa5a21..bedf6b4 100644 --- a/dbus/dbus-message-util.c +++ b/dbus/dbus-message-util.c @@ -182,6 +182,13 @@ _dbus_check_fdleaks_enter (void) if (fd == dirfd (d)) continue; + if (fd >= FD_SETSIZE) + { + _dbus_verbose ("FD %d unexpectedly large; cannot track whether " + "it is leaked\n", fd); + continue; + } + FD_SET (fd, &fds->set); } @@ -227,6 +234,13 @@ _dbus_check_fdleaks_leave (DBusInitialFDs *fds) if (fd == dirfd (d)) continue; + if (fd >= FD_SETSIZE) + { + _dbus_verbose ("FD %d unexpectedly large; cannot track whether " + "it is leaked\n", fd); + continue; + } + if (FD_ISSET (fd, &fds->set)) continue; -- 2.9.3