Commit Graph

9210 Commits

Author SHA1 Message Date
Philip Withnall
17d8a9adfa Merge branch 'mcatanzaro/ywh-131' into 'main'
gunixmounts: fix out of bounds write in AIX mount table parser

See merge request GNOME/glib!4895
2025-11-03 11:39:57 +00:00
Philip Withnall
2f345da831 gunixmounts: fix another out of bounds write in AIX mount table parser
Along the same lines as the previous commit, as suggested by Marco
Trevisan.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-11-03 11:16:45 +00:00
Sebastian Wick
3287ba22a1 gdbusinterfaceskeleton: Use a vfunc for method dispatching
This allows libdex to use a GDBusInterfaceSkeleton subtype to dispatch
method calls in fibers.
2025-11-02 11:18:37 +00:00
Sebastian Wick
e2bc9c1aba tests/codegen: Add tests for the new extension system
This makes sure that extensions can generate code at the expected
places, and change the GDBusInterfaceSkeleton subtype that generated
skeletons derive from.
2025-11-02 11:18:37 +00:00
Sebastian Wick
47a109c241 gdbus-codegen: Allow extensions to override the InterfaceSkeleton type
The libdex gdbus-codegen extension will use a GDBusInterfaceSkeleton
subtype to dispatch method calls in a fiber.
2025-11-02 11:18:37 +00:00
Sebastian Wick
4405fe5fc8 gdbus-codegen: Add an extension system which allows hooking codegen
The extension points are chosen by what libdex needs to generate future
based method calls.
2025-11-02 11:18:37 +00:00
Sebastian Wick
07ba38449e gdbus-codegen: Add a few more sync/async/finish comments 2025-11-02 11:18:37 +00:00
Sebastian Wick
df0315d125 gdbus-codegen: Add name_upper to Methods and ns_lower to Interfaces
We already have those variants on other classes, and they will become
useful in the libdex codegen extension.
2025-11-02 11:18:37 +00:00
Sebastian Wick
1b9ea4db35 gdbus-codegen: Add copy_func to Args
This allows us to create a copy of an argument without going through
GValue. The codegen here does not have any use for it, but we will add
an extension system in a later commit. The libdex codegen extension will
make use of it to define a boxed type for the method return values.
2025-11-02 11:18:37 +00:00
Sebastian Wick
ad42abd311 gdbus-codegen: Use the non-pointer type for ctype_out
The out type can be different from the in types in their qualifiers and
thus are not always simply a reference to the in type. However, the out
types used to include the reference instead of the "base" type because
the code generator always used them in places where we actually needed a
reference to the out type (e.g. as out params).

For example, the codegen here generates:

    gboolean dex_dbus_ping_pong_call_ping_sync (
        DexDbusPingPong *proxy,
        const gchar *arg_name,
        gchar ** out_pong,
        GCancellable *cancellable,
        GError **error);

Where `gchar **` is the out type. If we want to codegen a function which
returns the out params in a struct, it would need to look like this:

    typedef struct _DexDbusPingPongPingResult
    {
      gchar * pong;
    } DexDbusPingPongPingResult;

Where neither the out type `gchar **` nor the in type `const gchar *` is
appropriate.

This changes the ctype_out to be the base type, and makes the codegen
add the reference explicitly.
2025-11-02 11:18:37 +00:00
Michael Catanzaro
4156f37a90 gunixmounts: fix out of bounds write in AIX mount table parser
A mount table is inherently trusted, so this isn't really a security
issue, but let's not write out of bounds. If anybody is still using GLib
on AIX, then you're welcome.

Discovery and patch credit: mhzcyber - Mohammad Hussam Alzeyyat

(I, Michael, only wrote this commit message and adjusted the
whitespace.)
2025-10-30 11:49:28 -05:00
André Barnabá Silva
dcf716945f gdbusserver: retry binding to unix addresses only when possible
This adds the condition that a new unix address is tried only when there
is enough space to append random character(s) before the address reach
the length of UNIX_PATH_MAX.

Before this change, creating a GDBusServer with unix addresses longer
than UNIX_PATH_MAX that existed in the filesystem would never return. A
test that expects G_IO_ERROR_ADDRESS_IN_USE in such scenario was added.
2025-10-29 03:23:01 -03:00
Philip Withnall
9249c40d77 Merge branch 'scan-build-fixes' into 'main'
Various scan-build fixes

Closes #3805

See merge request GNOME/glib!4875
2025-10-27 23:17:25 +00:00
Philip Withnall
4937534257 glocalfileoutputstream: Fix error handling for a corner case
If asked to replace a file (i.e. effectively delete and re-create it)
which is a symlink, in a read-only directory, the code would end up
trying to do operations on an invalid `fd`. This was masked when asked
to create a backup, as creating the backup in the read-only
directory would error out just in time.

Make the code a bit more robust in this situation, and add some unit
tests.

Spotted by scan-build.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-10-27 21:33:54 +00:00
Alan Coopersmith
db165063f0 gio: add fallback implementation of g_memory_monitor_base_query_mem_ratio
Fallback for non-Linux systems that support the _SC_PHYS_PAGES and
_SC_AVPHYS_PAGES sysconf selectors, such as Solaris & OpenBSD.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2025-10-27 21:28:59 +00:00
Philip Withnall
3b20cc978b Merge branch 'wip/3v1n0/fd-query-path' into 'main'
glib-unix: Add API to lookup file path from FD

Closes #3806

See merge request GNOME/glib!4876
2025-10-22 12:44:34 +00:00
Patrick Griffis
549ed21ea1 gresolver: Fix loopback detection of IPv6 addresses
Previously the len passed to g_socket_address_new_from_native() was only
for IPv4 addresses and the constructor would fail.

This was reported and discussed here:
fe0139ee98 (note_2581394)
2025-10-21 15:43:21 -05:00
Marco Trevisan (Treviño)
dda9b9cc79 gio/tests/fake-document-portal: Use g_unix_fd_query_path()
Fixes: bc35a149
Closes: #3806
2025-10-21 19:17:46 +02:00
Marco Trevisan (Treviño)
10e9072634 gio/fake-desktop-portal: Use g_unix_fd_query_path 2025-10-21 19:17:46 +02:00
André Barnabá Silva
9222f71753 glocalfileinfo: implement _g_stat_{a,c,m}_nsec for macOS
add implementations for these functions using st_{a,c,m}timespec when
__APPLE__ is defined. Also re-enable the g-file-info test for darwin.

Fixes #3070, #2608
2025-10-20 23:37:42 -03:00
Sebastian Dröge
bdd51aa8ca Mark return value of g_dbus_interface_get_info() as nullable
`GDBusProxy` implements this interface but allows construction with a
`NULL` interface info and also marks its getter/setter for the interface
info accordingly.

Callers of `g_dbus_interface_get_info()` need to assume that it can
return `NULL` unless they constructed the `GDBusInterface` in a way that
guarantees that the interface info is available.
2025-10-20 20:47:38 +00:00
Philip Withnall
bbc508b78f gnetworkmonitorbase: Add missing notify::connectivity signal
The connectivity is directly derived from the `is_available` variable,
so if that changes, we need to notify of a change in `connectivity` too.

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

Fixes: #3803
2025-10-20 16:15:45 +01:00
Luca Bacci
5a3231dbda GIO/Win32: Remove custom definitions of system interfaces 2025-10-17 10:46:01 +02:00
Marco Trevisan
618d45cc83 Merge branch 'snap-document-portal-launch' into 'main'
GDesktopAppInfo: Use document portal to open all the URIs for snaps

See merge request GNOME/glib!4822
2025-10-17 04:00:20 +02:00
Marco Trevisan (Treviño)
bc35a1496d gio/gdesktopappinfo: Also use document portal for desktop file snaps
When a snap is launched from its non-dbus-activable desktop file we may
still need to use the portal to pass the URIs to the program, so that it
can access to them even if confined.

In fact most snaps are not dbus-activable, but they rely on the classic
desktop file activation.
2025-10-17 03:48:55 +02:00
Marco Trevisan
bd4b57e811 Merge branch 'scan-build-fixes' into 'main'
Fix various scan-build errors

See merge request GNOME/glib!4866
2025-10-17 03:47:16 +02:00
Philip Withnall
d904f77770 gunixmounts: Silence a scan-build false positive about a file handle leak
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-10-17 00:27:02 +01:00
Marco Trevisan (Treviño)
29fdcec8f3 gio/tests/desktop-app-info: Check child exit status
We need to ensure that the child we launch is not failing otherwise it
won't be possible to catch any assertion failure that it may happen
2025-10-17 01:07:33 +02:00
Philip Withnall
3e1176e4b8 Merge branch 'socket-control-docs' into 'main'
gsocketcontrolmessage: Fix a minor typo in a doc comment

See merge request GNOME/glib!4858
2025-10-16 21:10:46 +00:00
Philip Withnall
0ab1866145 Merge branch '3798-appinfo-portal-crash' into 'main'
gopenuriportal: Fix a crash when the file can’t be opened

Closes #3798

See merge request GNOME/glib!4859
2025-10-16 21:04:12 +00:00
Marco Trevisan (Treviño)
23c2483703 gio/gdesktopappinfo: Use document portal to open URIs for dbus-started snaps
Snap applications like flatpak apps may need to use the portals to open
files, so use the same logic that we have for flatpaks but using the
snap ID that matches portal expectations
2025-10-16 22:12:00 +02:00
Philip Withnall
21179497cf Merge branch 'zero-terminated-annotations' into 'main'
gio: add some nullable / zero-terminated annotations

See merge request GNOME/glib!4789
2025-10-16 20:10:49 +00:00
Marco Trevisan (Treviño)
85ec0256fe gio/tests/dbus-appinfo: Ensure that a dbus application has been opened
We were checking the results of opening an sandboxed application, but
never if the open was actually invoked.

So if another desktop file was used in tests, we were never getting any
failure, at least not related to the lack of a file being opened
2025-10-16 22:10:14 +02:00
Marco Trevisan (Treviño)
3159c3f806 dbus-appinfo: Generalize the flatpak appplication as a sandboxed app
So that we can use it for both flatpaks and snaps
2025-10-16 22:05:27 +02:00
François Laignel
7d032f2fde gio: add some nullable / zero-terminated annotations 2025-10-16 19:36:56 +00:00
Philip Withnall
5917bce3de gopenuriportal: Fix a crash when the file can’t be opened
Rather than reporting an error via a new `GTask`, report it via the
`GTask` we’ve already created. This avoids a critical warning about
destroying the `GTask` without returning a result.

Also ensure to disconnect the D-Bus signal subscription first, to avoid
an assertion failure in `call_data_free()`.

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

Fixes: #3798
2025-10-16 20:28:19 +01:00
Philip Withnall
9b03809a16 gsocketcontrolmessage: Fix a minor typo in a doc comment
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-10-16 20:28:01 +01:00
Marco Trevisan (Treviño)
b3a7c087ee gio/tests/gapplication: Check the values received on action activation
As per commit 0144feb41 the activate action paramter may pack multiple
values but while the behavior was checked we did not check the content
of the values we were receiving in the action callback.

So, also ensure that the variant values we receive are matching the
expectations.
2025-10-16 19:16:26 +00:00
Marco Trevisan (Treviño)
085deb7697 gio/tests/documentportal: Add tests covering portal failures
In case the portal fails to create what we expect, or we can't read the
files we should fail. Add test cases for this too.
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
fb0ee7562b gio/gdocumentportal: Get portal file name by listing the mount point
Instead of guessing the portal file name by using the original file name
let's just inspect the portal document ID directory and get the actual
file name
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
a3b99ce554 gio/tests/fake-document-portal: Really create fake files
In order to properly test the document portal, let's also create some
dummy files that are named after the FDs we receive and using the
document-id path as the real portal does
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
eb78cfeeca gio/tests/fake-document-portal: Test that the app-id matches the request
Ensure that the app-id requiring the document matches the one we want,
so that we can actually test the code in GDesktopAppInfo that does the
mapping
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
3eb2abb406 fake-document-portal: Fix signature of function callback
We were missing a parameter, as per the generated bindings
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
352cfe600a gio/gdocumentportal: Use the target name when opening a symlink
When an URI to a symlink is added to the portal, we open it and we send
the FD (of the target) to the portal. This one has no clue about the original
symlink and so it mounts a file that is named like the target.

g_document_portal_add_documents(), however returns a path that contains
the original name and that one is what is sent to the applications when
used via GDesktopAppInfo.

Basically, this is the situation:
  - /tmp/symlink -> /tmp/target
  - An application is launched to open file:/tmp/symlink
  - The portal creates file:/$XDG_RUNTIME_DIR/doc/ID/target
  - Gio converts the path to file:/$XDG_RUNTIME_DIR/doc/ID/symlink

Now, since we can't just pass the symlink to the portal without also
changing the logic there, it's just better to do the conversion ourself,
and so, we use the already-opened fd to figure out the real path of the
opened file, and we return a document file URI that uses the target
basename instead
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
d81701de56 gio/tests: Add document portal tests
While this can be tested using desktop apps, adding some unit tests
makes simpler to verify the edge cases
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
ddc324da03 gio/tests/fake-document-portal: Use a sequential ID for docs
It makes things clearer to test
2025-10-16 20:29:32 +02:00
Luca Bacci
b623031e22 glib-compile-resources: print error message when the temp file cannot be created 2025-10-16 13:16:58 +00:00
FeRD (Frank Dana)
9e049b9008 Entity tags: Link to RFC9110 for HTTP ETag reference
The RFC9110 explanation of HTTP ETags is far superior to
the disjoint ramblings found in (now-obsoleted) RFC2616,
and serves as a much better reference for comparison
with GFile entiity tags. Also, link directly to relevant section.
2025-10-02 11:06:41 +00:00
Philip Withnall
5b88afa767 Merge branch 'keep-suffix-name-when-trashing' into 'main'
GLocalFile: keep suffix name when trashing

See merge request GNOME/glib!4838
2025-09-30 16:00:01 +00:00
Philip Withnall
b7d8d88931 Merge branch 'file-equal-docs' into 'main'
gfile: Expand documentation around file equality

See merge request GNOME/glib!4815
2025-09-30 15:29:59 +00:00