Commit fc0f2965 authored by Simon McVittie's avatar Simon McVittie
Browse files

fdpass test: Assert that we don't leak file descriptors

Reproduces: #294


Reproduces: CVE-2020-12049
Reproduces: GHSL-2020-057
Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
parent 872b085f
...@@ -92,6 +92,7 @@ typedef struct { ...@@ -92,6 +92,7 @@ typedef struct {
GQueue messages; GQueue messages;
int fd_before; int fd_before;
DBusInitialFDs *initial_fds;
} Fixture; } Fixture;
static void oom (const gchar *doing) G_GNUC_NORETURN; static void oom (const gchar *doing) G_GNUC_NORETURN;
...@@ -176,6 +177,8 @@ test_connect (Fixture *f, ...@@ -176,6 +177,8 @@ test_connect (Fixture *f,
if (f->skip) if (f->skip)
return; return;
f->initial_fds = _dbus_check_fdleaks_enter ();
g_assert (f->left_server_conn == NULL); g_assert (f->left_server_conn == NULL);
g_assert (f->right_server_conn == NULL); g_assert (f->right_server_conn == NULL);
...@@ -875,6 +878,11 @@ teardown (Fixture *f, ...@@ -875,6 +878,11 @@ teardown (Fixture *f,
if (f->fd_before >= 0 && close (f->fd_before) < 0) if (f->fd_before >= 0 && close (f->fd_before) < 0)
g_error ("%s", g_strerror (errno)); g_error ("%s", g_strerror (errno));
#endif #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 int
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment