Commit graph

4417 commits

Author SHA1 Message Date
Simon McVittie
2381b81d05 more NEWS, also more release name 2015-05-14 15:04:36 +01:00
Simon McVittie
6986e22be1 1.9.16 2015-05-14 14:50:24 +01:00
Simon McVittie
b57223d701 Merge branch 'dbus-1.8'
Conflicts:
	NEWS
2015-05-14 14:45:04 +01:00
Simon McVittie
db31c8995e add a missing change, fix some bug numbers 2015-05-14 14:43:53 +01:00
Simon McVittie
1c4f87ca28 Merge branch 'dbus-1.8'
Conflicts:
	NEWS
	cmake/CMakeLists.txt
	configure.ac
2015-05-14 14:41:06 +01:00
Simon McVittie
bcdead0fd4 Fail to generate random bytes instead of falling back to rand()
This is more robust against broken setups where we run out
of memory or cannot read /dev/urandom.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
[smcv: document @error]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-14 14:30:30 +01:00
Simon McVittie
f385324d8b Make UUID generation failable
Previously, this would always succeed, but might use
weak random numbers in rare failure cases. I don't think
these UUIDs are security-sensitive, but if they're generated
by a PRNG as weak as rand() (<= 32 bits of entropy), we
certainly can't claim that they're universally unique.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
[smcv: document @error]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-14 14:30:30 +01:00
Simon McVittie
49646211f3 _dbus_server_init_base: raise a DBusError
This can currently only fail from OOM, but I'm about to make
it possible to fail from insufficient entropy.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
[smcv: document @error]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-14 14:30:30 +01:00
Simon McVittie
f180a83972 _dbus_server_new_for_socket: raise a DBusError
This can currently only fail due to OOM, but I'm about to
make it possible to fail for other reasons.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
[smcv: correct failure to set error in one case; document @error]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-14 14:30:30 +01:00
Simon McVittie
084977cfe2 Security hardening: force EXTERNAL auth in session.conf on Unix
DBUS_COOKIE_SHA1 is dependent on unguessable strings, i.e.
indirectly dependent on high-quality pseudo-random numbers
whereas EXTERNAL authentication (credentials-passing)
is mediated by the kernel and cannot be faked.

On Windows, EXTERNAL authentication is not available,
so we continue to use the hard-coded default (all
authentication mechanisms are tried).

Users of tcp: or nonce-tcp: on Unix will have to comment
this out, but they would have had to use a special
configuration anyway (to set the listening address),
and the tcp: and nonce-tcp: transports are inherently
insecure unless special steps are taken to have them
restricted to a VPN or SSH tunnelling.

Users of obscure Unix platforms (those that trigger
the warning "Socket credentials not supported on this Unix OS"
when compiling dbus-sysdeps-unix.c) might also have to
comment this out, or preferably provide a tested patch
to enable credentials-passing on that OS.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-14 14:30:30 +01:00
Simon McVittie
31489e1c4f start towards 1.8.20 2015-05-14 14:30:08 +01:00
Simon McVittie
1788e8f93d 1.8.18 2015-05-14 13:28:38 +01:00
Ralf Habacker
954371eea2 dbus_daemon_publish_session_bus_address: Fix -Wsign-compare issue.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90089
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-14 12:32:09 +01:00
Simon McVittie
4df63ce80b NEWS 2015-05-13 18:52:23 +01:00
Simon McVittie
b9a5ea27f9 Avoid reading beyond the length of a variable
Appending &some as DBUS_TYPE_INT64, DBUS_TYPE_UINT64 or DBUS_TYPE_DOUBLE,
where "some" is an int, reads beyond the bounds of that variable.
Use a zero-filled DBusBasicValue instead.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=30350
2015-05-13 18:44:44 +01:00
Simon McVittie
c8b2d74503 Fix whitespace as per Havoc's review (in 2010)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=30350
2015-05-13 18:44:44 +01:00
Christian Dywan
8e83c6e4d5 Implement dbus_message_iter_get_element_count
According unit tests are added to _dbus_message_test.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=30350
Reviewed-by: Havoc Pennington <hp@pobox.com>
2015-05-13 18:44:42 +01:00
Simon McVittie
ae56222048 DBusSocket: put the #ifdef case before the !defined case
This avoids the confusing #ifndef...#else anti-pattern.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:37:07 +01:00
Ralf Habacker
36e9dace74 Convert mostly DBUS_SOCKET_... and DBUS_POLLABLE_.. macros for more type safety.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-12 18:36:24 +01:00
Simon McVittie
f5e1c1391f Turn DBusSocket into a type-safe struct, preventing inappropriate conversion
Fix the remaining platform-specific code to look at the struct's
appropriate platform-specific member.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
2015-05-12 18:35:56 +01:00
Simon McVittie
54395bd5ad Remove _dbus_socket_is_invalid, no longer used
It didn't have many users anyway, and I've replaced them with the
DBUS_SOCKET_IS_VALID macro.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:35:49 +01:00
Simon McVittie
68d8c66680 Convert miscellaneous socket APIs to DBusSocket
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:35:38 +01:00
Simon McVittie
bbbd79b6ea generic socket transport code: work in terms of DBusSocket
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:35:24 +01:00
Simon McVittie
21ca7f7cc3 Split _dbus_set_fd_nonblocking vs. _dbus_set_socket_nonblocking
The former is Unix-specific, the latter is also portable to Windows.
On Unix, they're really the same thing.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:35:13 +01:00
Simon McVittie
378e01c0d0 main: reload_pipe is (despite its name) a socket pair
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:34:56 +01:00
Simon McVittie
520802f8c2 DBusMainLoop, DBusSocketSet: work in terms of DBusPollable
This requires generic support for keying hash tables by DBusPollable:
there are already implementations for int and uintptr_t keys, but not
for "int or uintptr_t depending on platform", which is what
DBusPollable now means.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
2015-05-12 18:34:32 +01:00
Simon McVittie
6ac3d6f70a Mostly remove the remnants of an older socket abstraction layer
This is only used on Windows, and wasn't even a particularly abstract
abstraction.

I've removed DBUS_SOCKET_IS_INVALID in favour of DBUS_SOCKET_IS_VALID
because I prefer to avoid double-negatives.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:34:24 +01:00
Simon McVittie
cc652d9f0c dbus-sysdeps: add more infrastructure around DBusSocket
This is all trivial right now, but will become significant when we
change DBusSocket into a type-safe struct.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:34:19 +01:00
Simon McVittie
064884f977 bus_unix_fds_passing_test: the results of _dbus_socketpair are sockets
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:33:50 +01:00
Ralf Habacker
ede75686ff Use typedef DBusSocket for sockets fd's to avoid conversion warnings.
[smcv: remove unneeded and invalid dbus-sysdeps.h from public header;
make prototype of _dbus_socketpair() consistent; undo conversion
of getaddrinfo result from int to SOCKET; don't call
_dbus_return_val_if_fail() from internal function]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
2015-05-12 18:33:43 +01:00
Simon McVittie
d9ab893182 Security hardening: force EXTERNAL auth in session.conf on Unix
DBUS_COOKIE_SHA1 is dependent on unguessable strings, i.e.
indirectly dependent on high-quality pseudo-random numbers
whereas EXTERNAL authentication (credentials-passing)
is mediated by the kernel and cannot be faked.

On Windows, EXTERNAL authentication is not available,
so we continue to use the hard-coded default (all
authentication mechanisms are tried).

Users of tcp: or nonce-tcp: on Unix will have to comment
this out, but they would have had to use a special
configuration anyway (to set the listening address),
and the tcp: and nonce-tcp: transports are inherently
insecure unless special steps are taken to have them
restricted to a VPN or SSH tunnelling.

Users of obscure Unix platforms (those that trigger
the warning "Socket credentials not supported on this Unix OS"
when compiling dbus-sysdeps-unix.c) might also have to
comment this out, or preferably provide a tested patch
to enable credentials-passing on that OS.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
2015-05-12 11:54:50 +01:00
Ralf Habacker
77e1b3110a reader_init: Initialize all fields of struct DBusTypeReader (CID 54754, 54772, 54773).
This patch is based on the fix for 'Field reader.array_len_offset is
uninitialized'

Reported by Coverity: CID 54754, 54772, 54773: Uninitialized scalar
variable (UNINIT)

[smcv: also re-order how the class is set when we recurse, so that
the sub-reader's class doesn't end up NULL]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
2015-05-08 15:54:42 +01:00
Simon McVittie
720e3ccb62 Merge branch 'dbus-1.8' 2015-05-08 15:37:58 +01:00
Simon McVittie
480f0182fa Revert "reader_init: Initialize all fields of struct DBusTypeReader (CID 54754, 54772, 54773)."
This reverts commit 21a7873f20.

This appears to cause a segfault, presumably resulting from something
assuming that reader_init() would not reinitialize all fields:

 #0  0x00007ffff7b74777 in _dbus_type_reader_get_current_type (reader=reader@entry=0x7fffffffda50) at .../dbus/dbus-marshal-recursive.c:791
 #1  0x00007ffff7b719d0 in _dbus_header_cache_check (header=<optimized out>)
    at .../dbus/dbus-marshal-header.c:209
 #2  0x00007ffff7b719d0 in _dbus_header_cache_check (header=header@entry=0x624658, field=field@entry=6) at .../dbus/dbus-marshal-header.c:250
 #3  0x00007ffff7b72884 in _dbus_header_get_field_basic (header=header@entry=0x624658, field=field@entry=6, type=type@entry=115, value=value@entry=0x7fffffffdbd8) at .../dbus/dbus-marshal-header.c:1365
 #4  0x00007ffff7b7d8c2 in dbus_message_get_destination (message=message@entry=0x624650) at .../dbus/dbus-message.c:3457
 #5  0x00007ffff7b67be6 in _dbus_connection_send_preallocated_unlocked_no_update (connection=connection@entry=0x6236d0, preallocated=0x0,
    preallocated@entry=0x6234c0, message=message@entry=0x624650, client_serial=client_serial@entry=0x7fffffffdcbc)
    at .../dbus/dbus-connection.c:2017
2015-05-08 15:36:19 +01:00
Ralf Habacker
84b2682eef auth_set_unix_credentials: Fix calling _dbus_credentials_add_pid without checking return value (CID 54708).
Reported by Coverity: CID 54708: Unchecked return value (CHECKED_RETURN)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-06 12:14:47 +02:00
Ralf Habacker
8b5788b2c2 auth_set_unix_credentials: Fix calling _dbus_credentials_add_unix_uid without checking return value (CID 54722).
Reported by Coverity: CID 54722: Unchecked return value (CHECKED_RETURN)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-06 12:14:44 +02:00
Ralf Habacker
5948bd13ed Merge remote-tracking branch 'origin/dbus-1.8' 2015-05-06 12:14:31 +02:00
Ralf Habacker
21a7873f20 reader_init: Initialize all fields of struct DBusTypeReader (CID 54754, 54772, 54773).
This patch is based on the fix for 'Field reader.array_len_offset is uninitialized'

Reported by Coverity: CID 54754, 54772, 54773: Uninitialized scalar variable (UNINIT)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-06 12:11:04 +02:00
Ralf Habacker
2e96b07e94 do_check_nonce: Fix of calling _dbus_string_append_len without checking return value (CID 54720).
Reported by Coverity: CID: Unchecked return value (CHECKED_RETURN)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-06 12:10:59 +02:00
Ralf Habacker
cc4c2d72bc dbus_message_demarshal: Fix calling _dbus_string_append_len without checking return value (CID 54690).
Reported by Coverity: CID 54690: Unchecked return value (CHECKED_RETURN)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-06 12:10:18 +02:00
Simon McVittie
e0f9ced769 Update NEWS for 1.9 branch 2015-05-05 12:50:20 +01:00
Simon McVittie
4c53a38ab5 Merge branch 'dbus-1.8' 2015-05-05 12:50:11 +01:00
Simon McVittie
d9d130d5fa NEWS for 1.8 branch 2015-05-05 12:43:47 +01:00
Adrian Szyndela
bbef8e4038 DBusCounter: add a mutex to protect the refcount and notify function
The overall problem here is that DBusCounter is indirectly linked
to a DBusConnection, but is not actually guaranteed to be protected by
that connection's mutex; and a DBusMessage can carry a reference to the
DBusCounter, resulting in freeing that DBusMessage having an effect on
the DBusCounter.

Making the refcount atomic would not be a sufficient fix, since it would
not protect the notify function: _dbus_counter_notify() could be called
indirectly by dbus_message_unref(), in an arbitrary thread that does not
hold the DBusConnection's lock, at the same time that the holder
of the DBusConnection lock calls _dbus_transport_set_max_message_size().

[smcv: added commit message]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89297
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-05 12:30:30 +01:00
Adrian Szyndela
bebe9ca993 extend lock's range in live_messages_notify()
The other code paths that ref or unref a transport are protected by
the DBusConnection's lock. This function already used that lock,
but for a narrower scope than the refcount manipulation.

live_messages_notify() could be triggered by unreffing messages
that originated from the same connection in a different thread.

[smcv: added commit message]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90312
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-05 12:27:15 +01:00
Ralf Habacker
20568ffb1f tools: MSVC compile fixes
unistd.h and sleep() are normally Unix-specific, although mingw also provides them.
The Windows C runtime documents _environ as its equivalent of Unix environ.

https://bugs.freedesktop.org/show_bug.cgi?id=90089
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-01 23:10:12 +02:00
Ralf Habacker
9979b9916f Merge remote-tracking branch 'origin/dbus-1.8'
Conflicts:
	cmake/test/CMakeLists.txt
	test/Makefile.am
2015-05-01 23:08:43 +02:00
Ralf Habacker
c396b8ea56 test_command_line_internal: Fix variable original_argv going out of scope leaks the storage it points to (CID 60588).
Reported by Coverity: CID 60588: Resource leak (RESOURCE_LEAK)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-01 23:05:14 +02:00
Ralf Habacker
53fbfe0c70 test_remove_directory: Fix 'variable iter going out of scope leaks the storage it points to' (CID 54729)
Reported by Coverity: CID 54729: Resource leak (RESOURCE_LEAK)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-01 23:05:09 +02:00
Ralf Habacker
e48dd5b3ca test_command_line_internal: Fix 'variable shell_argv going out of scope leaks the storage it points to' (CID 54751)
Reported by Coverity: CID 54751: Resource leak (RESOURCE_LEAK)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-01 23:05:05 +02:00