Commit graph

5458 commits

Author SHA1 Message Date
Simon McVittie
ea0275aaea bus_config_parser_check_doctype: Remove, unused
We have never checked the <!DOCTYPE> of busconfig XML since the libxml
parser was removed in 2013, and the libxml parser was broken before
that anyway. The recommended Expat parser (our only parser since 2013)
does not appear to have ever validated this, so now does not seem like
the time to start. Just ignore the <!DOCTYPE> if there is one.

(We never validated this particularly strictly anyway;
<!DOCTYPE busconfig SYSTEM "http://example.com/bees"> would have been
treated as perfectly valid.)

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107739
2018-08-30 17:39:38 +01:00
Simon McVittie
488ed14cc0 containers test: Exercise GetConnectionInstance() on dbus-daemon itself
This is an easy bit of missing test coverage detected by running the
test suite with gcov.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107739
2018-08-30 17:39:37 +01:00
Simon McVittie
10124ae11e BusConfigParser test: Check that all limits are equal, not just one
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107739
2018-08-30 17:39:35 +01:00
Simon McVittie
2b8c1b0813 bus_context_get_policy: Remove, unused
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107739
2018-08-30 17:39:34 +01:00
Simon McVittie
a3800e2d41 bus_connections_get_context: Remove, unused
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107739
2018-08-30 17:39:33 +01:00
Simon McVittie
170adbd6af bus_connections_foreach, bus_connections_foreach_active: Remove
These do not appear in code coverage statistics, and `git grep`
reveals that they are unused.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107739
2018-08-30 17:39:31 +01:00
Simon McVittie
28ca69d896 dbus-cleanup-sockets: Mark functions noreturn as suggested by clang
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107739
2018-08-30 17:39:21 +01:00
Simon McVittie
4d9aeac3cd Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-08-30 17:33:16 +01:00
Simon McVittie
7de841d7d9 Do not apply __attribute__((__malloc__)) to dbus_realloc()
As noted in GLib commit c879f50f, gcc's interpretation of the malloc
attribute has become more strict over time, which could result in
miscompilation. The new definition is that in addition to assuming
that the returned memory block is newly-allocated, gcc now assumes
that it does not contain any valid pointers. This is OK for
uninitialized or zero-initialized memory returned by dbus_malloc()
or dbus_malloc0(), but not valid for dbus_realloc(), which might be
used for a dynamically-sized array of (structures containing)
valid pointers.

See https://gitlab.gnome.org/GNOME/glib/issues/1465

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107741
2018-08-30 17:25:36 +01:00
Francesco Turco
b805744029 Distribute source code using .tar.xz archives
This saves around 32% of the size of the archive.

[smcv: Rebased onto current master]
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107630
2018-08-29 17:57:43 +01:00
Simon McVittie
e93b421137 build: Don't install a ChangeLog that we don't update
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107630
2018-08-29 17:57:22 +01:00
Simon McVittie
4297abd3d8 Remove old changelogs from git
The changelogs (and the commits themselves, converted to git format)
are still in the git history if anyone needs them.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
https://bugs.freedesktop.org/show_bug.cgi?id=107630
2018-08-29 17:57:13 +01:00
Simon McVittie
18aeb6975f build: Don't ship detailed changelogs for releases over 10 years old
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107630
2018-08-29 17:56:53 +01:00
Simon McVittie
d98c43c697 server-unix: Don't leak address of systemd server on success
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107320
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-08-23 18:23:34 +01:00
Simon McVittie
7ae750c4e8 bus: Free address (from --address) when we have finished using it
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107320
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-08-23 18:23:21 +01:00
Simon McVittie
2949a860da CONTRIBUTING: Reference the freedesktop.org Code of Conduct
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-08-22 17:50:18 +01:00
Simon McVittie
e4ec7ecbab Rename HACKING to CONTRIBUTING
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-08-22 17:48:42 +01:00
Simon McVittie
f96431b409 1.13.7 2018-08-03 01:01:11 +01:00
Simon McVittie
91e17e7685 1.13.6 2018-08-02 19:34:51 +01:00
Simon McVittie
7e6b3abcf8 Update NEWS 2018-08-02 19:23:52 +01:00
Simon McVittie
e93a775e68 validate_body_helper: Bounds-check before validating booleans
Running the "embedded tests" through valgrind revealed that before this
commit, we would have been willing to read up to 3 bytes off the end of
a message if the message is truncated part way through a boolean. Any
practical allocator will round up allocations to the next 32-bit (or
larger) boundary, so in practice this will not leave the memory buffer
(and in particular did not crash during unit testing), but it could read
uninitialized contents.

On little-endian CPUs, an attacker might be able to use this to learn
whether up to 3 bytes of uninitialized memory in the dbus-daemon
were all-zero (their crafted message would be relayed) or not (their
connection would be disconnected for sending an invalid message). On
big-endian CPUs, an attacker might be able to use this to learn whether
up to 3 bytes were all-zeroes (relayed to a cooperating peer), 0-2
bytes of all-zeroes followed by 0x01 (relayed to a cooperating peer),
or something else (disconnected). This is not believed to be exploitable
to leak interesting information.

Fixes: 62e46533 "hardcode dbus_bool_t to 32 bits"
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107332
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Thiago Macieira <thiago@kde.org>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-08-02 19:20:32 +01:00
Simon McVittie
5f02cfeb03 Update NEWS 2018-08-02 18:50:36 +01:00
Simon McVittie
375bffed7b Don't do OOM testing under valgrind by default
It's just painfully slow, particularly when we fork (as we do in
test-bus to test service activation).

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:17:15 +01:00
Simon McVittie
bbe7935196 dispatch test: Simplify OOM testing
Instead of having separate test wrappers for the cases that do and
don't take a DBusConnection, we can just pass a NULL DBusConnection
to the one that doesn't.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:17:07 +01:00
Simon McVittie
bb73c756f1 Skip name-test/ when running under valgrind for now
These tests are very reliant on their custom LOG_COMPILER,
which AX_VALGRIND_CHECK replaces.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:16:52 +01:00
Simon McVittie
8177bbcf52 tests: Detach most connections from main loop before closing
We don't need to do this for connections that were never set up
with the main loop.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:16:43 +01:00
Simon McVittie
620406f757 test/containers: Fix some memory leaks
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:16:27 +01:00
Simon McVittie
8095e52e5c test/marshal: Don't leak a message and its marshalled buffer
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:16:14 +01:00
Simon McVittie
294e8b0b67 nonce: Don't try to rmdir(NULL) on OOM
If re-initializing the string fails, it will be left in a state
where it has a length of 0 and a NULL buffer. That's valid to
"free", but not valid to pass to rmdir().

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:15:29 +01:00
Simon McVittie
b274bc13c3 test/dbus-daemon: Don't leak expected error for max connections
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:15:21 +01:00
Simon McVittie
d0413de71b test/dbus-daemon: Don't leak error if no machine ID was found
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:15:14 +01:00
Simon McVittie
07d6eab420 Allow longer for tests under valgrind
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:15:05 +01:00
Simon McVittie
e95dc1d58f tests: Call dbus_shutdown()
Not all of these tests will be fully valgrind-clean yet (or perhaps
ever), but it's easier to add this to all of them than to think
about it.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:14:39 +01:00
Simon McVittie
769c367f73 tests: Interpret empty command-line arguments as --tap
AX_VALGRIND_CHECK overrides LOG_COMPILER, which means we can't rely
on running under glib-tap-test.sh. Default to TAP mode by modifying
our (effective) argv instead.

If you really want the default behaviour (unstructured output) this
can still be achieved by adding some arguments that are a no-op,
such as `-m quick`.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:14:21 +01:00
Simon McVittie
1c36fc0aa5 tests: Detach server from main loop during teardown
test_server_setup() takes a reference to the DBusServer, so we need
to release that ref by calling test_server_shutdown().
test_server_shutdown() also disconnects the server, so we don't need
to do that.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:14:11 +01:00
Simon McVittie
b14a4517a8 dbus_server_listen: Don't leak first_connect_error
If an implementation fails to listen, and a subsequent implementation
succeeds, then we would have leaked this. Detected by running
tests/loopback.c under valgrind.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:10:48 +01:00
Simon McVittie
532d6d7cae loopback: Don't free credentials borrowed from the connection
We currently get away with this because the connection isn't fully
freed before we exit, but the connection is meant to own the result
of _dbus_connection_get_credentials() (it's "(transfer none)" in
GLib terminology).

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:10:19 +01:00
Simon McVittie
8868aac95d dbus_server_listen: Assert that implementations return a known result
If they didn't, we'd probably leak the server and/or the error.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:08:40 +01:00
Simon McVittie
b940ccdbd1 Assert that DBUS_SERVER_LISTEN_ADDRESS_ALREADY_USED does not set error
The only place this is set in practice is in dbus-server-win.c, which
does not set the error. If it did, dbus_server_listen() would leak it.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
2018-08-02 17:08:05 +01:00
Simon McVittie
58be2ad035 Update NEWS 2018-08-02 15:29:46 +01:00
Simon McVittie
f429631365 sysdeps: Reassure gcc 8 that we are not overflowing struct sockaddr_un
Using strncpy (buffer, str, strlen (str)) is a "code smell" that
might indicate a serious bug (it effectively turns strncpy into
strcpy), and gcc 8 now warns about it. In fact we avoided the bug
here, but it wasn't at all obvious.

We already checked that path_len is less than or equal to
_DBUS_MAX_SUN_PATH_LENGTH, which is 99, chosen to be strictly less
than the POSIX minimum sizeof(sun_path) >= 100, so we couldn't
actually be overflowing the available buffer.

The new static assertion in this commit matches a comment above the
definition of _DBUS_MAX_SUN_PATH_LENGTH: we define
_DBUS_MAX_SUN_PATH_LENGTH to 99, because POSIX says struct
sockaddr_un's sun_path member is at least 100 bytes (including space
for a \0 terminator). dbus will now fail to compile on
platforms that are non-POSIX-compliant in this way, except for Windows.

We zeroed the struct sockaddr_un before writing into it, so stopping
one byte short of the end of sun_path ensures that we get \0
termination.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107350
Reviewed-by: Thiago Macieira <thiago@kde.org>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-08-02 15:26:53 +01:00
Simon McVittie
963ce92f68 test: Avoid g_queue_foreach
In gcc 8, -Wall -Wextra includes -Wcast-function-type, which warns
about passing an extra (unwanted) parameter to callbacks. Instead
of using g_list_foreach(), open-code the equivalent.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107349
Reviewed-by: Thiago Macieira <thiago@kde.org>
2018-08-02 15:26:47 +01:00
Simon McVittie
9b21aab77f dbus_connection_dispatch: Avoid using _dbus_list_foreach
In gcc 8, -Wall -Wextra includes -Wcast-function-type, which warns
about passing an extra (unwanted) parameter to callbacks. Instead
of using _dbus_list_foreach(), open-code the equivalent here.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107349
Reviewed-by: Thiago Macieira <thiago@kde.org>
2018-08-02 15:26:36 +01:00
Simon McVittie
46cdc12830 Add and use _dbus_list_clear_full
In gcc 8, -Wall -Wextra includes -Wcast-function-type, which warns
about passing an extra (unwanted) parameter to callbacks. Instead
of using _dbus_list_foreach(), add a function to do what we actually
wanted here.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107349
Reviewed-by: Thiago Macieira <thiago@kde.org>
2018-08-02 15:26:27 +01:00
Simon McVittie
7efc06293a Rename dbus_internal_do_not_use_get_uuid to _dbus_get_uuid
This was the only remaining symbol using the long prefix. Renaming it
gives us one consistent rule: symbols starting with dbus are public,
symbols starting with _dbus are not.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107349
Reviewed-by: Thiago Macieira <thiago@kde.org>
2018-08-02 15:26:24 +01:00
Simon McVittie
a20c5b4d6f test: Don't use dbus_internal prefix for functions not in libdbus
As in the previous commit, this prefix is meaningless in translation
units that don't get compiled into libdbus.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107349
Reviewed-by: Thiago Macieira <thiago@kde.org>
2018-08-02 15:26:01 +01:00
Simon McVittie
9bd10615a0 message-util: Make more functions static (and remove useless prefix)
The naming convention dbus_internal_do_not_use_foo() was for functions
that had to be exported by libdbus but called by the embedded tests.
This is obsolete (in favour of _dbus_foo()) now that we have
DBUS_PRIVATE_EXPORT, and is doubly useless in this case because these
functions aren't even in libdbus - they're local to dbus-message-util.c.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107349
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-08-02 15:25:25 +01:00
Simon McVittie
09300a5e6f test: Fix signature of dbus_internal_do_not_use_try_message_file
In gcc 8, -Wall -Wextra includes -Wcast-function-type, which warns
about casting a function pointer to an incompatible type. In this
case the cast was because we were ignoring the void * argument, which
in this case is NULL. Since this function is only used within
dbus-message-util.c anyway, we might as well just use the correct
signature and remove the cast.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107349
Reviewed-by: Thiago Macieira <thiago@kde.org>
2018-08-02 15:24:55 +01:00
Simon McVittie
b387bd4d29 containers test: Record the unconfined manager connection's unique name
This is a bit more convenient than fetching it as-needed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105656
2018-06-21 17:43:52 +01:00
Simon McVittie
3837cd4d8a containers test: Factor out fixture_disconnect_observer
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105656
2018-06-21 17:43:48 +01:00