From: Philip Withnall Date: Wed, 22 Feb 2017 10:56:56 +0000 (+0000) Subject: dbus: Fix writing off the end of an fd_set when testing with Valgrind X-Git-Tag: dbus-1.11.12~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=55d692b88e5a8f675a0999a71f696148041e3e76;p=thirdparty%2Fdbus.git dbus: Fix writing off the end of an fd_set when testing with Valgrind 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 Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99839 --- diff --git a/dbus/dbus-message-util.c b/dbus/dbus-message-util.c index 9fa5a21cb..bedf6b4f8 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;