diff options
author | Simon McVittie <smcv@collabora.com> | 2020-04-16 14:41:48 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2020-06-02 11:13:17 +0100 |
commit | 7131a48004afab19926474547b50f046d12a4581 (patch) | |
tree | 81e0b0179d3b2b18890dac1761db18d832b31f5b | |
parent | 3418f4e500e6589e21bfcc545b3d4d1d70b17390 (diff) | |
download | dbus-7131a48004afab19926474547b50f046d12a4581.tar.gz |
fdpass test: Assert that we don't leak file descriptors
This version is for the dbus-1.10 branch, and doesn't rely on dbus!153
or dbus!120.
Reproduces: dbus#294
Reproduces: CVE-2020-12049
Reproduces: GHSL-2020-057
Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r-- | test/fdpass.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/fdpass.c b/test/fdpass.c index 665b4a12..d8d9c670 100644 --- a/test/fdpass.c +++ b/test/fdpass.c @@ -50,6 +50,14 @@ #include "test-utils-glib.h" +#ifdef DBUS_ENABLE_EMBEDDED_TESTS +#include <dbus/dbus-message-internal.h> +#else +typedef struct _DBusInitialFDs DBusInitialFDs; +#define _dbus_check_fdleaks_enter() NULL +#define _dbus_check_fdleaks_leave(fds) do {} while (0) +#endif + /* Arbitrary; included here to avoid relying on the default */ #define MAX_MESSAGE_UNIX_FDS 20 /* This test won't work on Linux unless this is true. */ @@ -91,6 +99,7 @@ typedef struct { GQueue messages; int fd_before; + DBusInitialFDs *initial_fds; } Fixture; static void oom (const gchar *doing) G_GNUC_NORETURN; @@ -172,6 +181,8 @@ test_connect (Fixture *f, { char *address; + f->initial_fds = _dbus_check_fdleaks_enter (); + g_assert (f->left_server_conn == NULL); g_assert (f->right_server_conn == NULL); @@ -835,6 +846,9 @@ teardown (Fixture *f, if (f->fd_before >= 0 && close (f->fd_before) < 0) g_error ("%s", g_strerror (errno)); #endif + + if (f->initial_fds != NULL) + _dbus_check_fdleaks_leave (f->initial_fds); } int |