summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2020-04-16 14:41:48 +0100
committerSimon McVittie <smcv@collabora.com>2020-06-02 10:42:54 +0100
commitfc0f29658353dd66b71a74ae2935276cd1410bc1 (patch)
tree4a820211ba6181a70e8d22ec667db8d1c72cc316
parent872b085f12f56da25a2dbd9bd0b2dff31d5aea63 (diff)
fdpass test: Assert that we don't leak file descriptors
Reproduces: dbus#294 Reproduces: CVE-2020-12049 Reproduces: GHSL-2020-057 Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r--test/fdpass.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/fdpass.c b/test/fdpass.c
index d84b7fe9..abd41504 100644
--- a/test/fdpass.c
+++ b/test/fdpass.c
@@ -92,6 +92,7 @@ typedef struct {
GQueue messages;
int fd_before;
+ DBusInitialFDs *initial_fds;
} Fixture;
static void oom (const gchar *doing) G_GNUC_NORETURN;
@@ -176,6 +177,8 @@ test_connect (Fixture *f,
if (f->skip)
return;
+ f->initial_fds = _dbus_check_fdleaks_enter ();
+
g_assert (f->left_server_conn == NULL);
g_assert (f->right_server_conn == NULL);
@@ -875,6 +878,11 @@ teardown (Fixture *f,
if (f->fd_before >= 0 && close (f->fd_before) < 0)
g_error ("%s", g_strerror (errno));
#endif
+
+ /* TODO: It would be nice if we could ask GLib which test-case
+ * we're currently in */
+ if (f->initial_fds != NULL)
+ _dbus_check_fdleaks_leave (f->initial_fds, "next test-case");
}
int