diff options
author | Philip Withnall <withnall@endlessm.com> | 2017-02-22 10:56:56 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2017-04-07 12:52:34 +0100 |
commit | 55d692b88e5a8f675a0999a71f696148041e3e76 (patch) | |
tree | 76498b44192f50401a0123f2d6bf4bdafe4d65dc /dbus/dbus-message-util.c | |
parent | 9a1e5372278d56e494b9d9421c1ba5254e73ccab (diff) | |
download | dbus-55d692b88e5a8f675a0999a71f696148041e3e76.tar.gz |
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 <withnall@endlessm.com>
Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99839
Diffstat (limited to 'dbus/dbus-message-util.c')
-rw-r--r-- | dbus/dbus-message-util.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/dbus/dbus-message-util.c b/dbus/dbus-message-util.c index 9fa5a21c..bedf6b4f 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; |