27789 Commits

Author SHA1 Message Date
Philip Withnall
428f92c7a8 Merge branch '2.78-bus-name-owners' into 'glib-2-78'
Backport !4038 “gdbusconnection: Don't deliver signals if the sender doesn't match” to glib-2-78

See merge request GNOME/glib!4040
2024-05-07 16:40:07 +00:00
Philip Withnall
e5c2170e23 Merge branch 'wip/smcv/2.78-no-msys-ci' into 'glib-2-78'
CI: Ignore MSYS2 CI failures for this older stable-branch

See merge request GNOME/glib!4043
2024-05-07 16:30:07 +00:00
Simon McVittie
23367e8445 gdbus-proxy test: Wait before asserting name owner has gone away
GDBusConnection sends each signal to recipients in a separate idle
callback, and there's no particular guarantee about the order in which
they're scheduled or dispatched. For the NameOwnerChanged signal that
reports the name becoming unowned, it's possible that g_bus_watch_name()
gets its idle callback called before the GDBusProxy:g-name-owner
machinery has updated the name owner, in which case the assertion
will fail.

Fixing GNOME/glib#3268 introduced a new subscription to NameOwnerChanged
which can alter the order of delivery, particularly in the case where
G_DBUS_PROXY_FLAGS_NO_MATCH_RULE was used (as tested in
/gdbus/proxy/no-match-rule). The resulting test failure is intermittent,
but reliably appears within 100 repetitions of that test.

Fixes: 511c5f5b "tests: Wait for gdbus-testserver to die when killing it"
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-05-07 16:21:47 +01:00
Simon McVittie
8a4afb8396 tests: Ensure that unsubscribing with GetNameOwner in-flight doesn't crash
This was a bug that existed during development of this branch; make sure
it doesn't come back.

This test fails with a use-after-free and crash if we comment out the
part of name_watcher_unref_watched_name() that removes the name watcher
from `map_method_serial_to_name_watcher`.

It would also fail with an assertion failure if we asserted in
name_watcher_unref_watched_name() that get_name_owner_serial == 0
(i.e. that GetNameOwner is not in-flight at destruction).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
92e4c83d17 tests: Add a test for signal filtering by well-known name
The vulnerability reported as GNOME/glib#3268 can be characterized
as: these signals from an attacker should not be delivered to either
the GDBusConnection or the GDBusProxy, but in fact they are (in at
least some scenarios).

Reproduces: https://gitlab.gnome.org/GNOME/glib/-/issues/3268
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
8104afb4f4 tests: Add a test for matching by two well-known names
The expected result is that because TEST_CONN_SERVICE owns
ALREADY_OWNED_NAME but not (yet) OWNED_LATER_NAME, the signal will be
delivered to the subscriber for the former but not the latter.
Before #3268 was fixed, it was incorrectly delivered to both.

Reproduces: https://gitlab.gnome.org/GNOME/glib/-/issues/3268 (partially)
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
0f22592185 gdbusconnection: Don't deliver signals if the sender doesn't match
Otherwise a malicious connection on a shared bus, especially the system
bus, could trick GDBus clients into processing signals sent by the
malicious connection as though they had come from the real owner of a
well-known service name.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3268
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
56aa0a2d05 gdbus: Track name owners for signal subscriptions
We will use this in a subsequent commit to prevent signals from an
impostor from being delivered to a subscriber.

To avoid message reordering leading to misleading situations, this does
not use the existing mechanism for watching bus name ownership, which
delivers the ownership changes to other main-contexts. Instead, it all
happens on the single thread used by the GDBusWorker, so the order in
which messages are received is the order in which they are processed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
1446111327 gdbusconnection: Stop storing sender_unique_name in SignalData
This will become confusing when we start tracking the owner of a
well-known-name sender, and it's redundant anyway. Instead, track the
1 bit of data that we actually need: whether it's a well-known name.

Strictly speaking this too is redundant, because it's syntactically
derivable from the sender, but only via extra string operations.
A subsequent commit will add a data structure to keep track of the
owner of a well-known-name sender, at which point this boolean will
be replaced by the presence or absence of that data structure.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
e4504a03ef gdbusconnection: Factor out remove_signal_data_if_unused
No functional change, just removing some nesting. The check for whether
signal_data->subscribers is empty changes from a conditional that tests
whether it is into an early-return if it isn't.

A subsequent commit will add additional conditions that make us consider
a SignalData to be still in use and therefore not eligible to be removed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
0bd037d154 gdbusconnection: Factor out add_signal_data()
No functional changes.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
735bf2cc81 gdbusconnection: Factor out signal_data_new_take()
No functional changes, except that the implicit ownership-transfer
for the rule field becomes explicit (the local variable is set to NULL
afterwards).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
0c6fac4526 gdbusconnection: Move SignalData, SignalSubscriber higher up
Subsequent changes will need to access these data structures from
on_worker_message_received(). No functional change here, only moving
code around.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
d7240bbd3b gdbusprivate: Add symbolic constants for the message bus itself
Using these is a bit more clearly correct than repeating them everywhere.
To avoid excessive diffstat in a branch for a bug fix, I'm not
immediately replacing all existing occurrences of the same literals with
these names.

The names of these constants are chosen to be consistent with libdbus,
despite using somewhat outdated terminology (D-Bus now uses the term
"well-known bus name" for what used to be called a service name,
reserving the word "service" to mean specifically the programs that
have .service files and participate in service activation).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
0df62f58d0 tests: Add test coverage for signals that match the message bus's name
This is a special case of unique names, even though it's syntactically
a well-known name.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
dfe0515ede tests: Add a test-case for what happens if a unique name doesn't exist
On GNOME/glib#3268 there was some concern about whether this would
allow an attacker to send signals and have them be matched to a
GDBusProxy in this situation, but it seems that was a false alarm.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
2a128c7ce0 tests: Add support for subscribing to signals from a well-known name
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Simon McVittie
b6a68c0e42 tests: Add a data-driven test for signal subscriptions
This somewhat duplicates test_connection_signals(), but is easier to
extend to cover different scenarios.

Each scenario is tested three times: once with lower-level
GDBusConnection APIs, once with the higher-level GDBusProxy (which
cannot implement all of the subscription scenarios, so some message
counts are lower), and once with both (to check that delivery of the
same message to multiple destinations is handled appropriately).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-07 16:21:47 +01:00
Philip Withnall
952852081d gdbusmessage: Cache the arg0 value
Technically we can’t rely on it being kept alive by the `message->body`
pointer, unless we can guarantee that the `GVariant` is always
serialised. That’s not necessarily the case, so keep a separate ref on
the arg0 value at all times.

This avoids a potential use-after-free.

Spotted by Thomas Haller in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3720#note_1924707.

[This is a prerequisite for having tests pass after fixing the
vulnerability described in glib#3268, because after fixing that
vulnerability, the use-after-free genuinely does happen during
regression testing. -smcv]

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3183, #3268
(cherry picked from commit 10e9a917be7fb92b6b27837ef7a7f1d0be6095d5)
2024-05-07 16:21:47 +01:00
Simon McVittie
336bca622e CI: Ignore MSYS2 CI failures for this older stable-branch
Release branches older than the current stable release are intended
for long-term-supported OS distributions such as Debian, RHEL or
Ubuntu LTS where GLib is part of the OS itself, and therefore an
OS vendor that wants to minimize regression risk in other OS components
might reasonably prefer to backport high-impact bug fixes instead of
upgrading to new GLib branches.

MSYS2 does not fall into that category: it is an add-on to an operating
system that does not contain GLib as OS functionality (namely, Windows),
making its maintainers less change-averse than LTS distribution vendors,
and in reality it has already upgraded its packaged GLib to 2.80.x.

Making these CI jobs non-blockers ensures that security fix releases
for LTS Linux distributions do not get held back by build failures on
a platform that is no longer interested in the relevant branch.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-05-07 16:16:12 +01:00
Ekaterine Papava
a963d3a8b5 Update Georgian translation 2024-03-25 04:54:25 +00:00
Ekaterine Papava
f8c50fd3ae Update Georgian translation 2024-03-19 07:48:35 +00:00
Philip Withnall
032f2a9135 Merge branch 'cherry-pick-41af4271' into 'glib-2-78'
gcontenttype: Make filename valid utf-8 string before processing

See merge request GNOME/glib!3960
2024-03-13 14:23:44 +00:00
Philip Withnall
227257515d tests: Remove variable-length lookbehind tests for GRegex
PCRE2 10.43 has now introduced support for variable-length lookbehind,
so these tests now fail if GLib is built against PCRE2 10.43 or higher.

See
e8db6fa713/ChangeLog (L94).

Rather than making the tests conditional on the version of PCRE2 in use,
just remove them. They are mostly testing the PCRE2 code rather than
any code in GLib, so don’t have much value.

This should fix CI runs on msys2-mingw32, which updated to PCRE2 10.43 2
days ago.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-03-13 14:11:24 +00:00
Juliano de Souza Camargo
36b81fbfb6 Update Brazilian Portuguese translation 2024-03-11 17:01:47 +00:00
Ondrej Holy
3bcc985987 gcontenttype: Make filename valid utf-8 string before processing
The `g_content_type_guess_for_tree` function segfaults currently when
processing filenames that are not valid unicode strings. Let's use the
`g_filename_to_utf8` and `g_utf8_make_valid` functions before other
processing to prevent that.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/3168


(cherry picked from commit 41af42717531a2af6dfd7a4f7b5c5fc228e85f0d)
2024-03-08 14:02:24 +00:00
Andi Chandler
557f0d9442 Update British English translation 2024-02-28 11:45:57 +00:00
Emmanuele Bassi
a4c9f9ac5e Merge branch 'wip/pwithnall/drop/freebsd-12-ci-glib-2-78' into 'glib-2-78'
glib-2-78: ci: Drop FreeBSD 12 CI runner as it’s EOL

See merge request GNOME/glib!3825
2024-01-22 10:44:35 +00:00
Philip Withnall
00edb7f745
2.78.4
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2.78.4
2024-01-21 19:48:20 +00:00
Philip Withnall
b9c6564154 ci: Temporarily disable --fatal-meson-warnings on FreeBSD CI
For the same reasons as in commit 71061fdcb33b8c26f5f8467c, but in this
case we can’t downgrade the version of Meson on the CI runner, so just
tell it to shut up instead.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-16 13:18:55 +00:00
Philip Withnall
aad088531d ci: Drop FreeBSD 12 CI runner as it’s EOL
It’s EOL and accordingly nobody wants to maintain the runner. We still
have the FreeBSD 13 runner to test against (on this branch and on
`main`).

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3740#note_1957840

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-15 21:53:33 +00:00
Michael Catanzaro
e93fd4cfc3 Merge branch 'backport-3750-regex-status-glib-2-78' into 'glib-2-78'
Backport !3750 “gregex: clean up usage of _GRegex.jit_status” to glib-2-78

See merge request GNOME/glib!3766
2023-12-18 21:58:47 +00:00
James Haggerty
d2d898d17b gregex: clean up usage of _GRegex.jit_status 2023-12-18 11:33:51 +00:00
Michael Catanzaro
d034b672ff Merge branch 'backport-3753-gdb-plugin-glib-2-78' into 'glib-2-78'
Backport !3753 “gobject_gdb.py: Do not break bt on optimized build” to glib-2-78

See merge request GNOME/glib!3759
2023-12-12 19:30:12 +00:00
Jens Georg
30efe593a1 gobject_gdb.py: Do not break bt on optimized build
Symptom:
20 0x00007ffff756337b in gtk_widget_size_allocate_with_baseline (widget=0xd7a0c0 [DirectWindow], allocation=, baseline=) at
gdb.error: value has been optimized out
2023-12-12 18:01:49 +00:00
Michael Catanzaro
f3ff370d1b Merge branch 'gtkdoc' into 'glib-2-78'
docs/reference: depend on a native gtk-doc

See merge request GNOME/glib!3756
2023-12-11 21:08:59 +00:00
Michael Catanzaro
f786d276e1 Merge branch 'backport-3751-rst-anchors-glib-2-78' into 'glib-2-78'
Backport !3751 “Fix generated RST anchors for methods, signals and properties” to glib-2-78

See merge request GNOME/glib!3754
2023-12-11 17:48:50 +00:00
Philip Withnall
a714556b3e tests: Re-format codegen.py with black
This is just the result of running `black $(git ls-files '*.py')`.

For some reason, the `sh-and-py-check` CI job didn’t run on merge
request !3751, so this non-standard formatting slipped through onto
`main`.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3754#note_1939914

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-11 16:56:14 +00:00
Philip Withnall
737b08e96f tests: Use textwrap.dedent to indent expected strings pleasingly
This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-11 16:56:14 +00:00
Ross Burton
54b081248a docs/reference: depend on a native gtk-doc
In a cross-compiled environment we don't need a target gtk-doc, but a
native gtk-doc.
2023-12-11 16:28:17 +00:00
tytan652
4e4471663c tests: Add tests for gdbus-codegen generated RST
Those tests check if methods, signals and properties documentation are
properly generated.
2023-12-11 14:21:29 +00:00
tytan652
a3189ec5c8 Fix generated RST anchors for methods, signals and properties 2023-12-11 14:21:29 +00:00
Philip Withnall
03f7c1fbf3
2.78.3
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2.78.3
2023-12-06 18:03:55 +00:00
Michael Catanzaro
171d65dffa Merge branch 'backport-3742-xdgmime-glib-2-78' into 'glib-2-78'
Backport !3742 “xdgmime: Update to upstream commit c2c814d4051f232” to glib-2-78

See merge request GNOME/glib!3747
2023-12-06 17:55:01 +00:00
Philip Withnall
facc4f06a3 xdgmime: Update to upstream commit c2c814d4051f232
(Modulo the changes in
https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/10 which are
still under discussion. Plus the proposed warning fixes from
https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/33.)

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3191
2023-12-06 16:33:39 +00:00
Philip Withnall
eb14755943
2.78.2
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2.78.2
2023-12-05 14:22:57 +00:00
Michael Catanzaro
e1aef8bfea Merge branch 'backport-3725-collate-checks-glib-2-78' into 'glib-2-78'
Backport !3725 “collate: Don't segfault on bad input” to glib-2-78

See merge request GNOME/glib!3727
2023-11-26 22:58:03 +00:00
Matthias Clasen
312352ed34 collate: Don't segfault on bad input 2023-11-26 22:46:04 +00:00
Michael Catanzaro
d8e89043c8 Merge branch 'backport-3714-xdgmime-glib-2-78' into 'glib-2-78'
Backport !3714 “xdgmime: Handle buggy type definitions with circular inheritance” to glib-2-78

See merge request GNOME/glib!3718
2023-11-22 16:04:33 +00:00
Alex Henrie
b382d059ee xdgmime: Add continue statements after goto labels in_xdg_mime_(cache_)mime_type_subclass
To fix the Android build.
2023-11-22 10:37:50 +00:00