26114 Commits

Author SHA1 Message Date
Philip Withnall
5c27f22aff gvariant: Zero-initialise various GVariantSerialised objects
The following few commits will add a couple of new fields to
`GVariantSerialised`, and they should be zero-filled by default.

Try and pre-empt that a bit by zero-filling `GVariantSerialised` by
default in a few places.

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

Helps: #2121
2022-12-13 19:01:00 +00:00
William Manley
f8f5d8eefa gvariant-serialiser: Factor out functions for dealing with framing offsets
This introduces no functional changes.

Helps: #2121
2022-12-13 19:01:00 +00:00
William Manley
590f7a6b76 gvariant-core: Consolidate construction of GVariantSerialised
So I only need to change it in one place.

This introduces no functional changes.

Helps: #2121
2022-12-13 19:01:00 +00:00
Ekaterine Papava
145cfe1e5f Update Georgian translation 2022-12-13 06:06:54 +00:00
Olga Smirnova
17672aeb4d Add Interlingue translation 2022-12-12 00:15:54 +00:00
Philip Withnall
28ba667276 tests: Add basic GApplicationCommandLine unit tests
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-08 14:46:47 +00:00
Philip Withnall
a6a847abab gapplication: Validate types of well-known platform data keys
The platform data comes from the parent process, which should normally
be considered trusted (if we don’t trust it, it can do all sorts of
other things to mess this process up, such as setting
`LD_LIBRARY_PATH`).

However, it can also come from any process which calls `CommandLine`
over D-Bus, so always has to be able to handle untrusted input. In
particular, `v`-typed `GVariant`s must always have their dynamic type
validated before having values of a static type retrieved from them.

Includes unit tests.

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

Helps: #1904
2022-12-08 14:46:47 +00:00
Philip Withnall
04b685ce27 gapplication: Document that command line options must be validated
They come from an external process, so they must be validated.

In particular, it’s always easy to forget to validate the type of a
`GVariant`, and just try to get the stored value using a well-known
type; but that’s a programming error if the `GVariant` actually stores a
different type. Always check the variant type first if loading from a
`v`.

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

Helps: #1904
2022-12-08 14:46:47 +00:00
Philip Withnall
32c1437a20 gfdonotificationbackend: Validate actions before activating them
These actions are activated as a result of receiving the `ActionInvoked`
signal from `org.freedesktop.Notifications`. As that’s received from
another process over D-Bus, it’s feasible that it could be malformed.
Without validating the action and its parameter, assertions will be hit
within the `GAction` code.

While we should be able to trust whatever process owns
`org.freedesktop.Notifications`, it’s possible that’s not the case, so
best validate what we receive.

Includes unit tests.

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

Helps: #1904
2022-12-08 14:46:47 +00:00
Philip Withnall
8be263c39d tests: Add stub tests for GFdoNotificationBackend
This test is fairly pointless, but puts the infrastructure in place for
adding more tests for `GFdoNotificationBackend` in upcoming commits.

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

Helps: #1904
2022-12-08 14:46:47 +00:00
Philip Withnall
e056220762 gfdonotificationbackend: Don’t remove notification if invoking action fails
Invoking an action on a notification should remove it (by default,
unless the `resident` hint is set, but GLib doesn’t currently support
that).

If, somehow, an invalid action is invoked on the notification, that
shouldn’t cause it to be removed though, because no action has taken
place. So change the code to do that.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-08 14:35:25 +00:00
Philip Withnall
07cd35a657 gapplication: Validate actions activated over D-Bus
As with the previous commit, the arguments to `ActivateAction` have to
be validated before being passed to `g_action_group_activate_action()`.
As they come over D-Bus, they are coming from an untrusted source.

Includes unit tests for all D-Bus methods on `GApplication`.

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

Helps: #1904
2022-12-08 14:35:25 +00:00
Philip Withnall
58cf769033 gactiongroupexporter: Validate actions activated or changed over D-Bus
The action name, parameter and new state are all controlled by an
external process, so can’t be trusted. Ensure they are validated before
being passed to functions which assert that they are correctly typed and
extant.

Add unit tests.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Backport: cherry-picked to glib-2-74, and additional braces added to
  avoid a `-Wdeclaration-after-statement` warning not present on `main`
  because we’ve dropped that warning on `main`

Helps: #1904
2022-12-08 14:35:25 +00:00
Philip Withnall
583ed7a954 tests: Move a helper function around in the actions test
This will be used in an upcoming commit.

This introduces no functional changes.

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

Helps: #1904
2022-12-08 14:28:02 +00:00
Philip Withnall
9513b31b9e tests: Add some missing error checks to actions test
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-08 14:27:58 +00:00
Philip Withnall
e5c00d29d4 tests: Stop using GMainLoop in actions test
Instead, iterate the `GMainContext` directly. This allows tests on
asynchronously returned values to be done in the actual test function,
rather than a callback, which should make the tests a little clearer.

This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-08 14:27:58 +00:00
Philip Withnall
9613412bb8 gtestdbus: Use g_timeout_add_seconds() rather than g_timeout_add()
This makes the code a little easier to understand and allows the kernel
a little bit more leeway in scheduling the callback, which is fine
because we don’t need high accuracy here.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-08 14:27:58 +00:00
Philip Withnall
74d1bd7b09 gnotificationbackend: Fix a GDBusConnection leak
`g_notification_backend_new_default()` adds a reference on
`backend->dbus_connection` (if non-`NULL`), but nothing ever unreffed
that.

Fix that by adding a dispose method.

In practice this is not really a problem, because the notification
backend is held alive by a `GApplication`, which lives as long as the
process. It’ll be a problem if someone is to ever add unit tests for
`GNotificationBackend`s though. So let’s fix it.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-08 14:27:58 +00:00
Philip Withnall
239ab99c46 gfdonotificationbackend: Improve internal docs around floating GVariants
The code is correct, but from a quick read-through it wasn’t entirely
clear to me how it handled floating `GVariant`s in object state or the
`parameter` argument.

Add an assertion and some comments to hopefully clarify things a little.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-12-08 14:27:58 +00:00
Nart Tlisha
049103370c Update Abkhazian translation 2022-12-02 10:33:24 +00:00
Philip Withnall
a8ad6347a4
2.74.2
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2.74.3
2022-12-01 14:03:47 +00:00
Simon McVittie
60d1ebbd2b Merge branch 'backport-3094-str-equal-cxx-glib-2-74' into 'glib-2-74'
Backport !3094 “gstrfuncs: Fix regression in C++ types accepted by g_str_equal()” to glib-2-74

See merge request GNOME/glib!3096
2022-11-30 13:46:05 +00:00
Philip Withnall
560e56fa71 gstrfuncs: Fix regression in C++ types accepted by g_str_equal()
Further to commit bcd364afef984da894045, fix the types accepted by the
`g_str_equal()` macro for C++ too. C++ is more restrictive about
const-correctness.

Add unit tests.

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

Fixes: #2820
2022-11-29 12:02:29 +00:00
Philip Withnall
b5299ed205
2.74.2
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2.74.2
2022-11-24 12:29:05 +00:00
Emmanuele Bassi
7908532046 Merge branch 'backport-3061-variant-maybe-wrapper-speedup-glib-2-74' into 'glib-2-74'
Backport !3061 “gvariant-parser: Speed up maybe_wrapper() by an order of magnitude” to glib-2-74

See merge request GNOME/glib!3063
2022-11-24 11:33:56 +00:00
Marco Trevisan
c7aa6e3bf4 Merge branch 'backport-3082-str-equal-api-break-glib-2-74' into 'glib-2-74'
Backport !3082 “gstrfuncs: Fix regression in types accepted by g_str_equal()” to glib-2-74

See merge request GNOME/glib!3084
2022-11-22 17:10:08 +00:00
Philip Withnall
b46ed37c97 gstrfuncs: Fix regression in types accepted by g_str_equal()
The new macro form of `g_str_equal()` had stricter type checking than
the original function form. That would be nice, except it causes new
compiler warnings in third party projects, which counts as an API break
for us, so unfortunately we can’t do it.

Add some tests to prevent regressions on this again.

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

Fixes: #2809
2022-11-22 16:14:51 +00:00
Мирослав Николић
25df888507 Update Serbian translation 2022-11-20 14:27:19 +00:00
Philip Withnall
64c2f5f3bb gvariant-parser: Speed up maybe_wrapper() by an order of magnitude
This further helps with the potential denial of service problem in
issue #2782 / oss-fuzz#49462 / oss-fuzz#20177.

Instead of allocating a new `GVariant` for each nesting level of
maybe-types, allocate a single `GVariant` and give it the fully-nested
maybe type as its type. This has to be done in serialised form.

This prevents attackers from triggering O(size of container × typedecl
depth) allocations.

This is a follow up to commit 3e313438f1900a620485ba88aad64c4e857f6ad1,
and includes a test.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Fixes: #2782
oss-fuzz#20177
oss-fuzz#49462
2022-11-08 17:12:40 +00:00
Nathan Follens
5ee5900459 Update Dutch translation 2022-11-02 19:09:03 +00:00
Ray Strode
fcdf5ebd81 Merge branch 'open-pipe-revert-2-74-backport' into 'glib-2-74'
Backport !3029 “Revert "Handling collision between standard i/o file descriptors and newly created ones" ” to glib-2-74

See merge request GNOME/glib!3039
2022-11-02 16:08:00 +00:00
Ray Strode
1c1c452ff2 glib-unix: Add test to make sure g_unix_open_pipe will intrude standard range
Now that we know it's a bad idea to avoid the standard io fd range
when getting pipe fds for g_unix_open_pipe, we should test to make sure
we don't inadvertently try to do it again.

This commit adds that test.
2022-11-02 09:26:47 -04:00
Ray Strode
2a36bb4b7e Revert "Handling collision between standard i/o file descriptors and newly created ones"
g_unix_open_pipe tries to avoid the standard io fd range
when getting pipe fds. This turns out to be a bad idea because
certain buggy programs rely on it using that range.

This reverts commit d9ba6150909818beb05573f54f26232063492c5b

Closes: #2795
Reopens: #16
2022-11-02 09:26:45 -04:00
Michael Catanzaro
6870d08d4b Merge branch 'backport-3045-proxy-resolver-tagging-glib-2-74' into 'glib-2-74'
Backport !3045 “gproxyresolver: lookup_finish() should better parallel lookup_async()” to glib-2-74

See merge request GNOME/glib!3046
2022-11-02 13:06:43 +00:00
Michael Catanzaro
299812d5ec gproxyresolver: lookup_finish() should better parallel lookup_async()
In g_proxy_resolver_lookup_async() we have some error validation that
detects invalid URIs and directly returns an error, bypassing the
interface's lookup_async() function. This is great, but when the
interface's lookup_finish() function gets called later, it may assert
that the source tag of the GTask matches the interface's lookup_async()
function, which will not be the case.

As suggested by Philip, we need to check for this situation in
g_proxy_resolver_lookup_finish() and avoid calling into the interface
here if we did the same in g_proxy_resolver_lookup_async(). This can be
done by checking the source tag.

I added a few new tests to check the invalid URI "asdf" used in the
issue report. The final case, using async GProxyResolver directly,
checks for this bug.

Fixes #2799
2022-11-02 09:49:57 +00:00
Simon McVittie
05fdb2d049 Merge branch 'backport-3035-portal-header-guard-glib-2-74' into 'glib-2-74'
Backport !3035 “portal: Fix broken header guard” to glib-2-74

See merge request GNOME/glib!3038
2022-11-02 02:01:03 +00:00
Robert Ancell
1304f9ed92 portal: Fix broken header guard
This wouldn't have caused an issue with the current header contents, but could have triggered a future bug.
2022-10-31 12:32:22 +00:00
Nart Tlisha
681980d382 Update Abkhazian translation 2022-10-31 10:03:40 +00:00
Marco Trevisan
a1151bc166 Merge branch 'backport-3008-wrapped-argv-leak-glib-2-74' into 'glib-2-74'
Backport !3008 “gio/gdesktopappinfo: Free the wrapped argv array on launch failure” to glib-2-74

See merge request GNOME/glib!3017
2022-10-26 11:47:08 +00:00
Marco Trevisan (Treviño)
efb43ef813 gio/gdesktopappinfo: Free the wrapped argv array on launch failure
We create an array that we never free, ensure this is the case.
The previous commit gives CI a chance to check this with valgrind job.

Found as part of another review:
 - https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2839#note_1524922
2022-10-26 10:30:09 +01:00
Philip Withnall
058491cb6f 2.74.1
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2.74.1
2022-10-25 13:53:22 +01:00
Philip Withnall
8fa92cf69b Merge branch 'backport-3009-timezone-relative-link-target-glib-2-74' into 'glib-2-74'
Backport !3009 “gtimezone: Fix symlink checks on relative link targets” to glib-2-74

See merge request GNOME/glib!3010
2022-10-25 12:23:15 +00:00
Fabio Tomat
142f1712d2 Update Friulian translation 2022-10-25 11:43:10 +00:00
Philip Withnall
14d5f25dd0 gfileutils: Mention possibility of relative paths in g_file_read_link()
It’s entirely possible that `g_file_read_link()` will return a relative
path. Mention that in the documentation, and include a short example of
how to make the path absolute for further computation.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-24 13:12:57 +01:00
Philip Withnall
0768067155 gtimezone: Fix symlink checks on relative link targets
The changes in 6265b2e6f70d6f0ec4d16adcdc5f7c53aecf0da4 to reject weird
`/etc/localtime` configurations where `/etc/localtime` links to another
symlink did not consider the case where the target of `/etc/localtime`
is a *relative* path. They only considered the case where the target is
absolute.

Relative paths are permissible in all symlinks. On my Fedora 36 system,
`/etc/localtime`’s target is `../usr/share/zoneinfo/Europe/London`.

Fix the check for toolbx by resolving relative paths before calling
`g_lstat()` on them.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-24 13:12:57 +01:00
Marco Trevisan
abac659264 Merge branch 'backport-2952-win32-test-fixes-glib-2-74' into 'glib-2-74'
Backport !2952 “Various win32 test fixes” to glib-2-74

See merge request GNOME/glib!2958
2022-10-21 16:02:36 +00:00
Marco Trevisan
957679f024 Merge branch 'backport-2947-gspawn-eintr-glib-2-74' into 'glib-2-74'
Backport !2947 “gspawn: avoid race due to retry with EINTR on close()” to glib-2-74

See merge request GNOME/glib!2988
2022-10-21 15:59:59 +00:00
Emmanuele Bassi
0e12b7d662 Merge branch 'backport-2934-floating-variants-grr-glib-2-74' into 'glib-2-74'
Backport !2934 “gobject: Always ref-sink variants in g_object_set” to glib-2-74

See merge request GNOME/glib!2998
2022-10-21 15:20:56 +00:00
Thomas Haller
7720c598f4 gspawn: use g_close()
g_close() now is async-signal-safe, as long as we don't request a GError
and pass a valid file descriptor.

Update "gspawn.c" to drop its safe_close() function and use
g_close() instead.
2022-10-21 15:38:27 +01:00
Thomas Haller
0cfc5b054a gstdio: make g_close() async-signal-safe under certain conditions
g_close() does something useful. It is not trivial to get EINTR handling of
close() right, in a portable manner. g_close() abstracts this.

We should allow glib users to use the function even in async-signal-safe
contexts, at least if the user heeds the caveat about GError and take care
not to fail assertions.

Backport 2.74: Modified to drop documentation changes to g_close() which
document its new async-signal-safe guarantees. They are not public
guarantees until 2.76. Also modified to include moving the code to
ignore `EINTR` from commit d5dc7d266f2b8d0f7d.
2022-10-21 15:37:33 +01:00