Commit Graph

7494 Commits

Author SHA1 Message Date
Philip Withnall
f300e883e7 codegen: Reformat parser.py according to black
This fixes the `style-check-diff` CI job.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-18 01:45:10 +00:00
Philip Withnall
425702df9c gresource-tool: Fix unused-but-set-variable warn with G_DISABLE_ASSERT
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-18 01:40:44 +00:00
Philip Withnall
9652a3dd79 gdebugcontrollerdbus: Track pending tasks with weak refs
Rather than tracking them with a counter. This should close the race in
tracking the finalisation of the tasks by the task worker thread.
There’s no way to synchronise with that thread as it’s internal to
`g_task_run_in_thread()`.

This should hopefully stop the `debugcontroller` test being flaky.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2486#note_1384102

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-18 00:46:07 +00:00
Philip Withnall
a09aca68d4 glib-compile-resources: Fix a memory leak of the compiler option
`G_OPTION_ARG_STRING` returns a newly allocated string, not a `const`
one.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-17 21:18:27 +00:00
Marc-André Lureau
9f2660fbae gio: fix OOB string access if filename is empty
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-16 18:54:03 +04:00
rim
37b39c525f Add cache to g_unix_mount_points_get() 2022-02-16 10:53:40 +00:00
Philip Withnall
c39c2a2821 Merge branch 'ebassi/issue-2601' into 'main'
Fix the DocBook codegen

Closes #2601

See merge request GNOME/glib!2489
2022-02-15 14:07:02 +00:00
Philip Withnall
b5873878cd Merge branch '1190-debugging-docs' into 'main'
gdebugcontroller: Add documentation and tests

Closes #1190

See merge request GNOME/glib!2486
2022-02-15 12:47:50 +00:00
Emmanuele Bassi
47ce6432f3 codegen: Verify that we're generating valid XML
We should output valid XML even when getting an iffy annotation.
2022-02-15 12:14:49 +00:00
Emmanuele Bassi
17f38affa2 codegen: Add missing closing angular bracket
We are matching `<parameter>` as well as `<para>`, and we
end up with broken XML in case the (expanded) description
starts with `<parameter>`.

Fixes: #2601
2022-02-15 11:51:11 +00:00
Emmanuele Bassi
6ddf760507 codegen: Remove flake8 lint rule
Using `flake8: noqa` disables ALL linting on a file. Adding
an error code does not limit the linter to that error.
2022-02-15 11:48:58 +00:00
Emmanuele Bassi
128ae2b5f5 codegen: Fix whitespace
This is Python, not C.
2022-02-15 11:48:28 +00:00
Emmanuele Bassi
fe3f699371 Add .flake8 file
The flake8 validation tool prefers an actual configuration
file to inline comments to disable the lint.
2022-02-15 11:47:30 +00:00
Philip Withnall
b7d3e3f16e tests: Add tests for GDebugController
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #1190
2022-02-14 14:42:17 +00:00
Philip Withnall
1b3e6bab53 gdebugcontrollerdbus: Add stop() method
This allows the controller to explicitly be removed from the bus, in a
way that allows the caller to synchronise with it and know that all
other references to the controller should have been dropped (i.e. after
this method returns, there should be no in-flight D-Bus calls still
holding a reference to the object).

This is needed to be able to guarantee finalisation of the controller in
unit tests (and comparable real-world situations).

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

Helps: #1190
2022-02-14 14:42:17 +00:00
Emmanuele Bassi
6c42c79d6c Use glib-compile-resource's compiler type
Since we call `glib-compile-resources` through a custom_target(), we
need to set the compiler type we're targeting.
2022-02-14 13:09:22 +00:00
Emmanuele Bassi
7bc6ef8734 Do not generate C resources for all possible toolchains
The resources data is generated for both GCC and MSVC toolchains, even
though we know beforehand which toolchain we're going to compile it for.
By dropping the data duplication we make the generated resources file
faster to compile, especially when dealing with large embedded data,
instead of relying on the C pre-processor to walk the whole file and
discard the branch we're not using.
2022-02-14 13:09:22 +00:00
Philip Withnall
11654811ef gdesktopappinfo: Add checks for empty argv
There shouldn’t be any issues here with empty argv arrays since an empty
`Exec=` line is already checked for. Encode that explicitly with an
assertion.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:42 +00:00
Philip Withnall
3ea4ba31a1 tools: Fix handling of empty argv in various minor GLib tools
This won’t really affect anything, but we might as well fix them to not
crash if called with an empty `argv` by someone (ab)using `execve()`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:42 +00:00
Philip Withnall
0d743e7ffb gapplicationcommandline: Handle the possibility empty args in an example
While it’s not usual, it is possible for applications to be called with
an empty `argv` by a process (ab)using `execve()`. Modify the
`GApplication` code example to handle that possibility, so that anyone
copying the example isn’t introducing a bug into their program
immediately.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:42 +00:00
Philip Withnall
fc6d0ba3a8 gapplicationcommandline: Fix a typo in a documentation comment
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:42 +00:00
Philip Withnall
95c6f3dc38 Merge branch '2329-application-cli-parsing' into 'main'
gapplication: Expose zero-valued numbers in handle-local-options

Closes #2329

See merge request GNOME/glib!1953
2022-02-11 12:40:37 +00:00
Philip Withnall
6d5953ee48 gdebugcontroller: Add some more documentation
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1190
2022-02-10 19:24:17 +00:00
Philip Withnall
35f6c65b35 giomodule: Ensure GDebugControllerDBus is registered
Or it’ll never work as a `GIOModule`, as the implementation won’t be
found.

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

Helps: #1190
2022-02-10 19:23:49 +00:00
Philip Withnall
a03920152f gdebugcontrollerdbus: Fix a typo in a D-Bus interface name
This was preventing `PropertiesChanged` signals from working.

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

Helps: #1190
2022-02-10 19:23:21 +00:00
Philip Withnall
29edfc1169 gdebugcontroller: Drop dup_default() method as it’s broken
If `GDebugControllerDBus` remains as the only, or default,
implementation of `GDebugController`, `dup_default()` cannot work.
`GDebugControllerDBus` requires a `GDBusConnection` at construction
time, which the `GIOModule` construction code can’t provide it.

Either we use a default D-Bus connection (but which one? and how would
it be changed by the user later if it was the wrong one?), or delegate
singleton handling of the `GDebugController` to the user.

The latter approach seems more flexible.

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

Helps: #1190
2022-02-10 19:21:24 +00:00
Philip Withnall
50d23f9680 Merge branch 'feature/move_async' into 'main'
Implement async file movement

See merge request GNOME/glib!2469
2022-02-07 14:29:52 +00:00
Lucas Schwiderski
9efde4c7fc Add test for async file move 2022-02-07 14:04:04 +00:00
Lucas Schwiderski
966f887cf9 Rename ambiguous struct 2022-02-07 14:03:47 +00:00
Lucas Schwiderski
eeb2bcf5a9 Implement async file movement 2022-02-07 14:03:47 +00:00
Zander Brown
aede29cb33 gfile: resolve_relative_path isn't nullable 2022-02-02 11:03:25 +00:00
Hu Jialun
7f044ba9c0 Amend g_bus_get* documentation regarding private connection 2022-01-28 13:11:34 +00:00
Philip Withnall
e01e6ef771 Merge branch 'windows-static-build-postfixes' into 'main'
Fix tests with static build on Windows

See merge request GNOME/glib!2442
2022-01-27 14:33:40 +00:00
Philip Withnall
cdda7bb59a Revert "Merge branch 'fix-windows-pc' into 'main'"
This reverts merge request !2459
2022-01-27 13:04:12 +00:00
Loic Le Page
38abadab3d Fix dbus process autolaunch with static build on Windows
On Windows, dbus is launched by spawning the gdbus.exe executable on
demand from the gio module. When linked dynamically, the executable
path is guessed relatively to the gio DLL path. But when linked
statically, the only reference path available is the current
executable path. In this case, gdbus.exe is not necessarily in the same
folder as the current executable.

This patch solves the issue using the same algorithm as the one used
with process spawning in glib core source code two commits above.
2022-01-27 12:10:13 +01:00
Philip Withnall
94f4ec85c6 Merge branch 'fix-memleak-gdbusauthmechanismsha1' into 'main'
Fix memory leak in gio/gdbusauthmechanismsha1.c

See merge request GNOME/glib!2461
2022-01-27 11:05:45 +00:00
Philip Withnall
7f519624e2 Merge branch '1190-debug-interface' into 'main'
gdebugcontroller: Add debug controller API and D-Bus implementation

Closes #1190

See merge request GNOME/glib!2330
2022-01-27 11:00:40 +00:00
Loic Le Page
6ec432386e Fix memory leak in gio/gdbusauthmechanismsha1.c 2022-01-27 10:39:49 +01:00
Sebastian Dröge
7f2de9ab83 Merge branch 'fix-windows-pc' into 'main'
gio: add missing zlib dependency in gio-windows-2.0.pc

See merge request GNOME/glib!2459
2022-01-27 08:45:53 +00:00
Simon McVittie
2eb1eb1649 Merge branch 'glib-compile-resources-build-improvements' into 'main'
tests: Pass --internal and -z noexecstack to glib-compile-resources tests

See merge request GNOME/glib!2456
2022-01-26 18:13:05 +00:00
Andoni Morales Alastruey
d2ab2bcefd gio: add missing zlib dependency in gio-windows-2.0.pc 2022-01-26 18:13:05 +01:00
Philip Withnall
0c8f7de55a gdebugcontroller: Add debug controller API and D-Bus implementation
This is intended to provide a uniform interface for controlling whether
the debug output from an application (or service) is emitted, typically
to journald, but actually to wherever the application chooses to output
it.

The main implementation of `GDebugController` is `GDebugControllerDBus`,
which is intended to be used on Linux. Other implementations may be
added in future for other platforms, or larger applications may want to
provide their own implementation which integrates with their ecosystem.

The `GDebugControllerDBus` implementation exposes a D-Bus interface at
`/org/gtk/Debugging` with a method to enable or disable debug
output at runtime.

This could be used by external harnesses, such as GNOME Builder or
systemd, to give a uniform way to get debug output from an application.

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

Fixes: #1190
2022-01-26 15:19:27 +00:00
Philip Withnall
9cde484b9f tests: Mark compiled resource file as not having an executable stack
As with the previous commit, this isn’t needed for GLib’s tests to work
correctly, but is probably needed in other projects which might be
tempted to copy and paste the Meson tooling from GLib.

Inspired by https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4330

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-01-26 14:28:46 +00:00
Philip Withnall
55fa866cc8 tests: Pass --internal to glib-compile-resources tests
This isn’t needed to make the tests any better (it doesn’t really affect
them), but is probably needed for anyone who copies this Meson code in
order to add `glib-compile-resources` support to their project. It’s
pretty unlikely that someone would want to compile *and export* a
resource from a shared library.

Inspired by https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4334

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-01-26 14:27:38 +00:00
Marc-André Lureau
9a9e2b5d7d gio: enable unix: address on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
e796124b31 gio: tests AF_UNIX socket credentials on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
95c3e28af5 gio: add G_CREDENTIALS_TYPE_WIN32_PID
Credentials are often used to check peer processes details.

With AF_UNIX sockets on Windows, SIO_AF_UNIX_GETPEERPID can
be used to retrive the peer PID.

We will probably introduce more advanced mechanisms later on, though,
but I am not a Windows API expert.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
568f00d65f gio/tests: enable most AF_UNIX tests on all platforms
The main difference is that g_socket_new_from_fd() requires bound
sockets on Win32.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
2f8a9196b8 gio: return G_IO_NVAL if the socket is already closed
For consistency with Unix behaviour, as checked in the tests/socket.c.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
83d45c4f35 gio: compile GUnixConnection on all platforms
On !UNIX, return an error for send_fd() & receive_fd().
(the unixfdmessage unit is not compiled on !UNIX)

The header is installed under the common GIO include directory.

Ensure G_TYPE_UNIX_CONNECTION is registered on all platforms.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
af1777d3d3 meson: compile GUnixCredentialsMessage on all platforms
The header is now also installed under the common GIO include directory.

Sorry if it breaks any build, you had to use the correct header path.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
37cab227fd gio: compile GSocketAddress with AF_UNIX on all platforms
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
3308cfb020 gio: compile GUnixSocketAddress on all platforms
Move the header under the common GIO include directory.

Sorry if it breaks any build, you had to use the correct header path.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
4339192b53 gio: add fallback afunix.h header
afunix.h is only recently distributed with Windows SDK & MinGW.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:23 +04:00
Sebastian Wilhelmi
c74177337d gdbusmessage: Disallow zero-length elements in arrays
They are not allowed in the specification, and can lead to infinite
loops when parsing.

That’s a security issue if your application is accepting D-Bus messages
from untrusted peers (perhaps in a peer-to-peer connection). It’s not
exploitable when your application is connected to a bus (such as the
system or session buses), as the bus daemons (dbus-daemon or
dbus-broker) filter out such broken messages and don’t forward them.

Arrays of zero-length elements are disallowed in the D-Bus
specification: https://dbus.freedesktop.org/doc/dbus-specification.html#container-types

oss-fuzz#41428, #41435
Fixes: #2557
2022-01-26 13:04:49 +00:00
Sebastian Wilhelmi
6499ad5356 gdbusmessage: Disallow empty structures/tuples in D-Bus messages
They are disallowed in the specification:
https://dbus.freedesktop.org/doc/dbus-specification.html#container-types

Helps: #2557
2022-01-26 13:04:49 +00:00
Loic Le Page
42c77c7ac7 Enable full-static build on Windows
Glib cannot be built statically on Windows because glib, gobject and gio
modules need to perform specific initialization when DLL are loaded and
cleanup when unloaded. Those initializations and cleanups are performed
using the DllMain function which is not called with static builds.

Issue is known for a while and solutions were already proposed but never
merged (see: https://gitlab.gnome.org/GNOME/glib/-/issues/692). Last
patch is from version 2.36.x and since then the
"constructor/destructor" mechanism has been implemented and used in
other part of the system.

This patch takes back the old idea and updates it to the last version of
glib to allow static compilation on Windows.

WARNING: because DllMain doesn't exist anymore in static compilation
mode, there is no easy way of knowing when a Windows thread finishes.
This patch implements a workaround for glib threads created by calling
g_thread_new(), so all glib threads created through glib API will behave
exactly the same way in static and dynamic compilation modes.
Unfortunately, Windows threads created by using CreateThread() or
_beginthread/ex() will not work with glib TLS functions. If users need
absolutely to use a thread NOT created with glib API under Windows and
in static compilation mode, they should not use glib functions within
their thread or they may encounter memory leaks when the thread finishes.

This should not be an issue as users should use exclusively the glib API
to manipulate threads in order to be cross-platform compatible and this
would be very unlikely and cumbersome that they may mix up Windows native
threads API with glib one.

Closes #692
2022-01-26 10:14:02 +01:00
Pablo Correa Gómez
d4cbe9ce4e
xdgmime: Fix unused-variable warning
../gio/xdgmime/xdgmimemagic.c:489:24: warning:
unused variable 'i' [-Wunused-variable]
  489 |           unsigned int i;
      |                        ^
2022-01-25 20:18:41 +01:00
Philip Withnall
e00069010e Merge branch 'win32-mem-monitor' into 'main'
gio/win32: add GMemoryMonitorWin32

See merge request GNOME/glib!2452
2022-01-25 18:11:53 +00:00
Marc-André Lureau
bb1b9d90ec gio/win32: add GMemoryMonitorWin32
Windows has CreateMemoryResourceNotification() API:

https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-creatememoryresourcenotification

It only notifies whether "Available physical memory is running low."

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-25 20:55:57 +04:00
Marc-André Lureau
0ed621e905 gio/tests: use g_message to print --watch result
g_debug() isn't printed by default.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-25 16:31:10 +04:00
Marc-André Lureau
06160facf3 gio/tests: simplify enum to string in memory-monitor
Also results in more robust handling, since it can get a NULL eclass.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-25 16:31:10 +04:00
Sebastian Dröge
1979bfed4b Add (array length) annotation to g_tls_certificate_new_from_pkcs12() 2022-01-25 12:39:18 +02:00
Emmanuele Bassi
ba2725f263 tests: Check "gdbus-codegen --generate-docbook"
Verify that the command line argument works, by checking it's not writing
to stdout/stderr, and that the generated file isn't empty.
2022-01-22 01:30:16 +00:00
Emmanuele Bassi
4db9d43f1a tests: Check "gdbus-codegen --generate-rst"
Verify that the command line argument works, by checking it's not writing
to stdout/stderr, and that the generate file isn't empty.
2022-01-22 01:30:16 +00:00
Emmanuele Bassi
e2fe3aa0e7 Build the reStructuredText docs for the object-manager example
Just like we build them for the DocBook. We are not including them in the
API reference, for now.
2022-01-22 01:30:16 +00:00
Emmanuele Bassi
66e4ba806a Add reStructuredText generator to gdbus-codegen
The gdbus-codegen tool generates documentation from the XML introspection
description of a D-Bus interface. Currently, only DocBook is supported at
the moment, but not every modern documentation generator can handle that
format. The reStructuredText format is a bit more well-supported,
especially in documentation generators for non-C languages.

Unlike DocBook, we get to make our own structure and conventions for how
we structure the documentation when using reStructuredText.
2022-01-22 01:30:16 +00:00
Emmanuele Bassi
5013d08315 codegen: Do not add extra paragraph elements while parsing
When parsing a comment we're adding <para> elements ourselves, but the
DocBook generator already wraps any block of text that does not start
with a <para> element with one.
2022-01-22 01:30:16 +00:00
Philip Withnall
aad2cbd2db Merge branch 'nacho/off_t' into 'main'
giowin32: use gint64 and _lseeki64

See merge request GNOME/glib!2447
2022-01-21 13:00:25 +00:00
Ignacio Casal Quinteiro
1a34988296 _g_stat_size: return goffset
Otherwise on windows we would be capped at 32bit off_t.
2022-01-20 12:22:18 +01:00
Ignacio Casal Quinteiro
1848905a99 credentials: support the local peerpid on macos
xucred does not provide the peer pid id, but this can be fetched
from the socket LOCAL_PEERPID option. Note that we only support
it when creating the credentials from a local socket, if
the credential comes from a message over a socket the peer
pid id will not be set and -1 will be returned when trying
to get the pid for the credential.
2022-01-20 10:52:01 +01:00
Simon McVittie
cc2b28b68c Merge branch 'dbus-external-sid' into 'main'
gdbus: make client work with EXTERNAL on Windows

See merge request GNOME/glib!2429
2022-01-19 18:38:20 +00:00
Marc-André Lureau
7d7b52edbd gio: make client connection work with EXTERNAL on win32
D-Bus reference implementation doesn't require more than the claimed
process SID as part of the AUTH initial data for EXTERNAL.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-18 22:09:03 +04:00
Marc-André Lureau
e66b9489b7 gio: re-use win32 SID helpers
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-18 22:08:16 +04:00
Maximiliano Sandoval R
525f20a247 docs: Replace broken link 2022-01-18 13:48:43 +00:00
Maximiliano Sandoval R
7118c16347 docs: Improve docs for gdbusutils.c 2022-01-18 13:48:43 +00:00
Marc-André Lureau
d4a66baadb gio: add win32 SID helper functions
The code is based from #1351 patch and existing similar code in
gdbusprivate.c. The next commit will replace that existing code with
those helpers.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-18 17:40:02 +04:00
Philip Withnall
ea18fcff58 Merge branch 'mwleeds/fix-codegen-typo' into 'main'
gdbus-codegen: Fix a typo in a comment

See merge request GNOME/glib!2426
2022-01-17 15:38:50 +00:00
Phaedrus Leeds
6342922d27 gdbus-codegen: Fix a typo in a comment 2022-01-11 20:03:13 -08:00
Patrick Griffis
96ce3feeb9 gtlscertificate: Add ability to load PKCS #12 encrypted files
This depends on the GTlsBackend implementing these properties
2022-01-07 11:27:56 -06:00
Ralf Habacker
229f7d4a03 Fix cross build error for Windows with gcc
This commit puts an additional underscore before the external symbol
`_g_binary_test1_resource_data` when using gcc for Windows, to match
the compiler's expectation.

Fixes #2571

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-01-06 09:20:54 +01:00
Kelvin Zhang
2a4422b0f2 Use meson dependency to link against apple framework
Using ld_flags would work, but that does not propagate ldflags to users
of glib. Meson's dependency() call will propagate apple framework
dependencies to downstream users.
2022-01-05 11:32:32 -08:00
Andy Russell
82ece18644
annotate g_content_type_guess parameter as filename 2021-12-28 15:36:54 -05:00
Philip Withnall
954a8724c2 xdgmime: Add missing S_ISREG definitions for VS2022
Otherwise building with VS2022 fails with:
```
Creating library D:/temp/29/.sw/out/323969/gnome.glib.gio-2.71.0.lib and object D:/temp/29/.sw/out/323969/gnome.glib.gio-2.71.0.exp
xdgmime.c.4b279509.obj : error LNK2019: unresolved external symbol S_ISREG referenced in function _gio_xdg_get_mime_type_for_file
xdgmimecache.c.79af418f.obj : error LNK2001: unresolved external symbol S_ISREG
D:\temp\29\.sw\out\323969\gnome.glib.gio-2.71.0.dll : fatal error LNK1120: 1 unresolved externals
```

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

Fixes: #2560
2021-12-23 12:35:48 +00:00
Philip Withnall
4d6da4457a gthreadedresolver: Tighten up types and constness of parsing code
Not everything should be an int. This code is quite dated. We now try to
use `guint8*` to represent arbitrary binary data, rather than `guchar*`
(which makes it sound like some form of string).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-12-15 17:04:20 +00:00
Patrick Griffis
49e667d250 gthreadedresolver: Export g_resolver_records_from_res_query()
While it’s not a supported public part of the API, exporting this
symbol from the library means we can easily test the DNS record parser,
which is important to do since it handles untrusted data from the
network.
2021-12-15 16:55:01 +00:00
Michael Catanzaro
376e2915e2 Add test for child_err_report_fd conflation with target fds
This tests for glib#2506.
2021-12-14 13:47:31 -06:00
Michael Catanzaro
d4c486779d Add tests for GSubprocess fd conflation issues
This tests for #2503. It's fragile, but there is no non-fragile way to
test this. If the test breaks in the future, it will pass without
successfully testing the bug, not fail spuriously, so I think this is
OK.
2021-12-14 13:47:31 -06:00
Michael Catanzaro
2a7547f8a5 gsubprocess: ensure we test fd remapping on the posix_spawn() codepath
We should run test_pass_fd twice, once using gspawn's fork/exec codepath
and once attempting to use its posix_spawn() codepath. There's no
guarantee we'll actually get the posix_spawn() codepath, but it works
for now on Linux.

For good measure, run it a third time with no flags at all.

This causes the test to fail if I separately break the fd remapping
implementation. Without this, we fail to test fd remapping on the
posix_spawn() codepath.
2021-12-14 13:45:39 -06:00
Philip Withnall
f493d3fd24 Merge branch 'cxx-test' into 'main'
Removing redundant cxx test tests/cxx-test.cpp

See merge request GNOME/glib!2391
2021-12-14 15:23:16 +00:00
Emmanuel Fleury
ae345e56c2 Distribute cxx test tests/cxx-test.cpp to each module tests directory
tests/cxx-test.cpp is removed and splitted into gio/tests/cxx.cpp,
gmodule/tests/cxx.cpp and gobject/tests/cxx.cpp.

Helps issue #1434
2021-12-14 14:43:03 +01:00
Ivaylo Dimitrov
f065497acf GDesktopAppInfo: Try to always correctly set id
Specs say that on Unix id should be desktop file id from the xdg menu
specification, however, currently code just uses basename of .desktop file.
Fix that by finding the .desktop file in all the desktop_file_dirs and use
basename only as a fallback.

See https://specifications.freedesktop.org/menu-spec/latest/go01.html#term-desktop-file-id
and https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s02.html#desktop-file-id

"To determine the ID of a desktop file, make its full path relative to the
$XDG_DATA_DIRS component in which the desktop file is installed, remove the
"applications/" prefix, and turn '/' into '-'."

Also, add unit test that verifies Desktop Id is being correctly set

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
2021-12-14 11:46:57 +00:00
Philip Withnall
72377e3b6e Merge branch 'new_alloca0_newa0' into 'main'
galloca: Add new API g_alloca0 and g_newa0

Closes #475

See merge request GNOME/glib!2367
2021-11-26 12:38:46 +00:00
Nishal Kulkarni
48d0d9f76b gsocket: Use new g_alloca0() function
Replace `g_alloca()` and `memset()` with `g_alloca0()`
2021-11-26 12:24:23 +00:00
Sebastian Dröge
5fcd2495f9 De-duplicate g_nearest_pow() implementation
And put it as static inline function into a private shared header instead.
2021-11-25 14:05:42 +02:00
Michael Catanzaro
f877b82573 gresolver: add missing locking
This is sad, but GResolver has one member variable for historical
reasons, to implement the reload signal. Since it offers a global
singleton, we should make sure it's really safe to use from multiple
threads at once.
2021-11-24 09:16:11 -06:00
Michael Catanzaro
6eb741a6ac gresolver: rename internal reload function
Since there is not actually anything to reload, let's just say we emit
the reload signal.
2021-11-24 09:16:11 -06:00
Michael Catanzaro
c2b5fe9f2d gresolver: remove unneeded call to res_init()
This call was needed once upon a time, when GResolver had subclasses
that presumably relied on this. Nowadays, we have only
GThreadedResolver, which does not need it. res_init() is dangerous
because it modifies global state, so let's get rid of it.
2021-11-24 09:16:11 -06:00
Nirbheek Chauhan
ed7c3dd343 Merge branch 'wip/pwithnall/freebsd-objcopy-fix-why-oh-why' into 'main'
tests: Allow `objcopy --help` to fail, because it fails on FreeBSD

See merge request GNOME/glib!2364
2021-11-24 15:12:15 +00:00
Luca Bacci
de6da5aa73
GWin32AppInfo: Implement should_show vfunc 2021-11-24 15:48:10 +01:00
Luca Bacci
ebddb60e3e
Add vfunc checks in gappinfo.c
Fixes crashes caused by calling unimplemented vfuncs on Windows
2021-11-24 15:06:46 +01:00
Philip Withnall
dc243a5113 tests: Allow objcopy --help to fail, because it fails on FreeBSD
This is a partial revert of b248f3481c. Eventually, this commit can be
dropped once `objcopy --help` doesn’t exit with a non-zero status on
FreeBSD.

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2360#note_1318608

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-24 12:01:39 +00:00
Philip Withnall
6bdb06ff4b Merge branch 'run_command-check' into 'main'
meson: specify when commands need to succeed in run_command

See merge request GNOME/glib!2360
2021-11-24 10:31:41 +00:00
Eli Schwartz
b248f3481c
meson: specify when commands need to succeed in run_command
meson in git master now warns about a missing `check:` kwarg, and may
eventually change the default from false to true.

Take the opportunity to require `objcopy --help` to succeed -- it is
unlikely to fail, but if it does something insane happened.
2021-11-24 00:31:18 -05:00
Aleksandr Mezin
bff4db527e gdbusproxy: Make 'g-signal' signal detailed
Fixes #2536
2021-11-23 22:14:19 +06:00
Philip Withnall
56b0b8069d Merge branch 'dbus-daemon-print-address-fd' into 'main'
gtestdbus: Print the dbus address on a specific FD intead of stdout

Closes #2537

See merge request GNOME/glib!2354
2021-11-23 13:32:24 +00:00
Marco Trevisan (Treviño)
d98a52254b gtestdbus: Print the dbus address on a specific FD intead of stdout
We used to use a pipe for the dbus daemon stdout to read the defined
address, but that was already requiring a workaround to ensure that dbus
daemon children were then able to write to stdout.
However the current implementation is still causing troubles in some
cases in which the daemon is very verbose, leading to hangs when writing
to stdout.

As per this, just don't handle stdout ourself, but use instead a
specific pipe to get the address address. That can now be safely closed
once we've received the data we need.

This reverts commit d80adeaa96.

Fixes: #2537
2021-11-23 13:07:50 +00:00
Philip Withnall
1f8390c002 gdbusmessage: Remove arbitrary restriction on minimum D-Bus blob length
The code in `g_dbus_message_new_from_blob()` has now been fixed to
correctly error out on all truncated messages, so there’s no need for an
arbitrary programmer error if the input is too short to contain a valid
D-Bus message header.

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

Helps: #2528
2021-11-23 12:57:29 +00:00
Sebastian Wilhelmi
c58be7d569 tests: Add test cases for truncated D-Bus messages
(Minor code formatting tweaks and leak fixes by Philip Withnall.)

Helps: #2528
2021-11-23 12:55:00 +00:00
Sebastian Wilhelmi
4b9a27a868 gdbusmessage: Add more bounds checking when parsing D-Bus messages
Perform strict bounds checking when reading data from the D-Bus message,
and propagate errors to the callers.

Previously, truncated D-Bus messages could cause out-of-bounds reads.

This is a security issue, but one which is only exploitable when
communicating with an untrusted peer (who might send malicious
messages). Almost all D-Bus traffic is with a session or system bus,
where the dbus-daemon or dbus-broker is trusted, and is known to have
already rejected malformed (malicious) messages.

Accordingly, this is only exploitable with peer-to-peer D-Bus
conversations with an untrusted peer.

(Includes some minor cleanups from Philip Withnall.)

oss-fuzz#17408
Fixes: #2528
2021-11-23 12:32:31 +00:00
Michael Catanzaro
82999879bc gtlsconnection: warn about footguns of using a non-default database
Since
https://gitlab.gnome.org/GNOME/glib-networking/-/merge_requests/173,
there is now a really surprising implication to using a non-default
GTlsDatabase: your database could do nothing at all other than wrap the
default database, which you would expect to result in no behavior
changes, but in fact it causes fewer security checks to be performed
during certificate verification. This is because certificate
verification moved from GTlsDatabase to GTlsConnection, allowing for
more security checks to be performed. But if using a non-default
GTlsDatabase, we have to fall back to letting GTlsDatabase to the
verification, as before.

This is the best we can do. It's not a regression for applications,
because it means applications get the previous pre-2.72 behavior. But it
does mean that new security checks added in 2.72 are not applied, which
is unfortunate, so we should warn developers about this.
2021-11-22 15:56:56 +00:00
Michael Catanzaro
a6a41cfc17 gtlscertificate: tone down warning about g_tls_certificate_verify() 2021-11-22 15:56:56 +00:00
Michael Catanzaro
5f585225a2 gtlsdatabase: tone down warning about g_tls_database_verify_chain()
This is only true for the default GnuTLS backend. It is not true for the
OpenSSL backend, so let's say "may" instead of "will."
2021-11-22 15:56:56 +00:00
Michael Catanzaro
3b3d56a45c gtlsdatabase: remove stray "Since: 2.70"
This feature has been reverted for now because I messed up the
implementation and it was doing sync I/O during async API calls. Oops!
Since it's not present in 2.70 nor in 2.72, let's remove the reference
to the exact GLib version that this behavior was introduced in. I'd like
to get it working properly for 2.74, but it's not ready yet and just
changing the version to 2.74 feels optimistic.
2021-11-22 15:56:56 +00:00
Sebastian Dröge
6d8045ddb4 Merge branch 'gdbus-call-interactive' into 'main'
gdbus: Add --interactive option to `gdbus call`

See merge request GNOME/glib!2329
2021-11-22 13:58:46 +00:00
Philip Withnall
8e185e12c9 tests: Fix a flaky wait in converter-stream
Rather than waiting for a fixed period of time, poll in a loop until the
condition the test is expecting is true.

A better solution would be to use a `GSource` and wait until that’s
dispatched. But doing so might affect the behaviour of the
`GInputStream` under test, so busy-wait instead.

Fixes this CI failure: https://gitlab.gnome.org/GNOME/glib/-/jobs/1630758

```
(some socket debug output)
Bail out! GLib-GIO:ERROR:../gio/tests/converter-stream.c:1037:test_converter_pollable: assertion failed (res == -1): (1 == -1)
```

I could not reproduce the failure remotely with a few hundred
invocations of the test, so it might only present itself on BSD, which
presumably has different socket timing behaviour from Linux.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-22 13:22:25 +00:00
Philip Withnall
40037ebbfc tests: Use g_assert_*() rather than g_assert() in converter-stream.c
`g_assert()` is compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-22 13:20:17 +00:00
Alexander Kanavin
e161c62292 gio/tests/codegen.py: bump timeout to 100 seconds
This may be necessary on overloaded CI systems.
2021-11-18 14:07:11 +01:00
Frederic Martinsons
296a8c6522 Sort output of gsettings command-line tool
Closes #1781

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-11-18 08:59:55 +01:00
Philip Withnall
b09ccc4635 Merge branch 'fix_all_warnings' into 'main'
Fix final warnings in Windows code

See merge request GNOME/glib!2323
2021-11-17 15:15:46 +00:00
Emmanuel Fleury
22037bfab2 Fix set but unused parameter warning in gio/tests/gio-du.c
gio/tests/gio-du.c: In function 'main':
gio/tests/gio-du.c:74:11: error: parameter 'argc' set but not used
   74 | main (int argc, char **argv)
      |       ~~~~^~~~
2021-11-17 14:40:38 +01:00
Emmanuel Fleury
dea0ec3df6 Fix signedness warning in gio/ginputstream.c
gio/ginputstream.c: In function 'g_input_stream_real_skip':
gio/ginputstream.c:433:31: error: comparison of integer expressions of different signedness: 'goffset' {aka 'long long int'} and 'long long unsigned int'
  433 |               (start + count) > (guint64) end)
      |                               ^
2021-11-17 14:40:38 +01:00
Emmanuel Fleury
264055f3c0 Fix signedness warnings in gio/gwin32appinfo.c
gio/gwin32appinfo.c: In function 'uwp_package_cb':
gio/gwin32appinfo.c:3383:17: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
   for (i = 0; i < supported_extgroups->len; i++)
                 ^
gio/gwin32appinfo.c:3389:29: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
       for (i_ext = 0; i_ext < grp->extensions->len; i_ext++)
                             ^
gio/gwin32appinfo.c:3430:35: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
           for (i_verb = 0; i_verb < grp->verbs->len; i_verb++)
                                   ^
gio/gwin32appinfo.c:3463:33: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
       for (i_hverb = 0; i_hverb < ext->verbs->len; i_hverb++)
                                 ^
gio/gwin32appinfo.c:3478:17: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
   for (i = 0; i < supported_protocols->len; i++)
                 ^
gio/gwin32appinfo.c:3541:33: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
       for (i_hverb = 0; i_hverb < url->verbs->len; i_hverb++)
                                 ^
gio/gwin32appinfo.c: In function 'g_win32_app_info_launch_internal':
gio/gwin32appinfo.c:4799:37: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
           for (p_index = 0; p_index <= g_strv_length (envp); p_index++)
                                     ^~
2021-11-17 14:40:38 +01:00
Emmanuel Fleury
f9b4a557b1 Fix signedness warning in gio/gwin32packageparser.c
gio/gwin32packageparser.c: In function 'WIN32_FROM_HRESULT':
gio/gwin32packageparser.c:99:30: warning: comparison of integer expressions of different signedness: 'long unsigned int' and 'long int'
   if ((hresult & 0xFFFF0000) == MAKE_HRESULT (SEVERITY_ERROR, FACILITY_WIN32, 0) ||
                              ^~
2021-11-17 14:40:28 +01:00
Hristo Venev
9bd4730008 gsubprocess: Add G_SUBPROCESS_FLAGS_SEARCH_PATH_FROM_ENVP 2021-11-17 12:27:46 +00:00
Philip Withnall
511c5f5bf0 tests: Wait for gdbus-testserver to die when killing it
This was previously done (by commit 63038d1e4c) in one of the cases
where `kill_test_service()` was called — but not the other.

This meant that one instance of `gdbus-testserver` could still be
around when (as it happens, due to the order of the tests) the
`/gdbus/proxy/no-match-rule` test was run. It would start a second
instance of `gdbus-testserver`, which would exit early due to the test
name still being owned on the bus. The first (killed) instance of
`gdbus-testserver` would then exit, leaving no test servers running, and
hence the new test would fail.

This was being seen as frequent CI failures, particularly on FreeBSD
(must have slightly different timing for process signalling and
termination from Linux).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-16 22:47:15 +00:00
Michael Catanzaro
d1e9e0c094 gsocketclient: deprecate tls-validation-flags property
It doesn't work as expected, and you shouldn't be trying to use it
anyway.
2021-11-16 15:21:22 +00:00
Michael Catanzaro
38de97c148 gtlsclientconnection: deprecate validation-flags property
It doesn't work as expected, and you shouldn't be trying to use it
anyway.
2021-11-16 15:21:21 +00:00
Michael Catanzaro
780af9cff3 Document potential footgun with GTlsCertificateFlags
Once upon a time, we tried to return all possible certificate errors,
but it never actually worked reliably and nowadays we have given up.
This needs to be documented because a reasonable developer would not
expect it.

Because mistakes could be security-critical, I decided to copy the same
warning in several different places rather than relying only on
cross-referencese.
2021-11-16 15:21:21 +00:00
Sebastian Dröge
6a7187cae4 Merge branch 'actions-test-fix' into 'main'
tests: Drop arbitrary and flaky waits from actions tests

See merge request GNOME/glib!2336
2021-11-16 14:37:24 +00:00
Maurice
366597a10d Fix GSettings dict error macOS 2021-11-16 14:21:00 +00:00
Philip Withnall
4eafbaba94 tests: Fix two small leaks in the actions test
These are known leaks, as they were being done in tests which were
checking precondition failures.

However, since we know what happens when the failures occur, we can
still free the input data reliably, so do that.

This improves the valgrind output for `actions` to show zero definite
leaks.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-16 14:03:36 +00:00
Philip Withnall
c8fa295f6a tests: Drop arbitrary and flaky waits from actions tests
The `actions` test previously waited an arbitrary 100ms for various
D-Bus messages to be sent/received, before checking the results of those
messages.

Normally, this would work, but on heavily loaded CI systems, it would
sometimes fail. For example,
https://gitlab.gnome.org/GNOME/glib/-/jobs/1611701.

Fix that by waiting for the condition being checked to evaluate to true,
rather than waiting an arbitrary period of time. On faster machines,
this will speed the tests up too.

Assume that the global default `GMainContext` is in use, so a
`GMainContext*` pointer doesn’t have to be passed around.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-16 14:01:24 +00:00
Emmanuel Fleury
9e3a08b222 Fix signedness warning in gio/gcontenttype-win32.c
gio/gcontenttype-win32.c: In function 'get_registry_classes_key':
gio/gcontenttype-win32.c:66:78: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'int'
               if (ExpandEnvironmentStringsW (wc_temp, wc_temp_expanded, len) == len)
                                                                              ^~
2021-11-12 14:58:52 +01:00
Philip Withnall
b75a16b048 gdbus: Add --interactive option to gdbus call
This allows the flag to allow interactive auth to be set. Previously, it
was unconditionally unset.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-11 11:26:22 +00:00
Lubomir Rintel
a107a328e4 gdbusproxy: Add G_DBUS_PROXY_FLAGS_NO_MATCH_RULE flag
D-Bus has an upper limit on number of Match rules and it's rather easy to hit
with a big number of proxies with signal subscriptions. This happens with
NetworkManager with hundreds of devices or connection settings. By passing
G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE to g_dbus_connection_signal_subscribe(), the
user can call AddMatch with a less granular match instead of a match per every
proxy.

Tests subsequently added by Philip Withnall.

Fixes: #1109
2021-11-04 11:44:18 +00:00
Michael Catanzaro
caf777984b Merge branch '2426-delayed-settings-null-handling' into 'main'
gdelayedsettingsbackend: Fix applying after calling g_settings_reset()

Closes #2426

See merge request GNOME/glib!2161
2021-11-03 18:03:21 +00:00
Philip Withnall
7be79cb840 Merge branch '2310-xdgmime-leaks' into 'main'
gcontenttype: Ignore intentional one-time leaks from xdgmime

Closes #2310

See merge request GNOME/glib!2268
2021-11-03 15:42:20 +00:00
Philip Withnall
fd080d8564 Merge branch 'list-model-doc-fixes' into 'main'
docs: Fix the GListModel description

See merge request GNOME/glib!2319
2021-11-03 11:46:28 +00:00
Philip Withnall
1161bd8078 Merge branch 'drop-old-xdgmime-change' into 'main'
Revert "Don't compile some unused functions in gio/xdgmime/"

See merge request GNOME/glib!2277
2021-11-02 09:28:22 +00:00
Emmanuele Bassi
192b3e6c2d docs: Fix the GListModel description
- Isolate the first meaningful paragraph, for gi-docgen's summary
- Describe get_object() as a binding API
- Fix reference to get_item() inside get_item_type()
2021-11-01 18:41:50 +00:00
Philip Withnall
726c44c348 Merge branch '2400-dbus-race' into 'main'
gdbusconnection: Fix race between method calls and object unregistration

Closes #2400

See merge request GNOME/glib!2265
2021-11-01 18:37:17 +00:00
Pablo Correa Gómez
14c5589ed6
gdbusaddress: setuid error message references AT_SECURE
g_check_setuid does more than setuid checks when using AT_SECURE.
Make sure that it is referenced in the error message to help
users debug in case or errors

Closes #2518
2021-11-01 15:54:55 +01:00
Philip Withnall
3dcae415a4 Revert "Don't compile some unused functions in gio/xdgmime/"
This reverts commit 14e46ca288.

Diverging from upstream xdgmime is a maintenance burden, and this
isn’t really much additional code to compile. It should be dropped by
the linker since it’s unused.

See https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/15.
2021-11-01 12:06:26 +00:00
Philip Withnall
e4bb09d8ec Merge branch 'fix-win32-app-info-registry-key-assert' into 'main'
GWin32AppInfo: Do not assert about successful open'ing of registry keys

See merge request GNOME/glib!2260
2021-11-01 10:41:31 +00:00
Philip Withnall
34ce204fd7 tests: Add D-Bus object/subtree unregistration tests
These tests cover the fixes from the previous two commits.

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

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
117b748e44 gdbusconnection: Fix race between subtree method call and unregistration
Fix another variant of the previous commit, this time specific to the
idle callback of a method call on a subtree object, racing with
unregistration of that subtree.

In this case, the `process_subtree_vtable_message_in_idle_cb()` idle
callback already has a pointer to the right `ExportedSubtree` struct,
but again doesn’t have a strong reference to it.

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

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
50fbf05d61 gdbusconnection: Fix race between method calls and object unregistration
If `g_dbus_connection_unregister_object()` (or `unregister_subtree()`)
was called from one thread, while an idle callback for a method call (or
a property get or set) was being invoked in another, it was possible for
the two to race after the idle callback had checked that the
object/subtree was registered, but before it had finished dereferencing
all the data related to that object/subtree.

Unregistering the object/subtree would immediately free the data,
leading the idle callback to cause a use-after-free error.

Fix that by giving the idle callback a strong reference to the data from
inside the locked section where it checks whether the object/subtree is
still registered.

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

Fixes: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
c8c2ed4af5 gdbusconnection: Make ExportedInterface/ExportedSubtree refcounted
This is needed for an upcoming change which decouples their lifecycle
from their presence in the `map_id_to_ei` and `map_id_to_es` hash
tables.

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

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
a497fdf302 gdbusconnection: Add some ownership annotations
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-28 14:53:48 +01:00
Philip Withnall
310f2c1632 gdbusconnection: Move ExportedSubtree definition
Move it further up the file, but make no changes to it. This will help
with a subsequent commit.

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

Helps: #2400
2021-10-28 14:53:48 +01:00
Philip Withnall
44cbba5d78 gsettings: Drop internal delayed member
This introduces no functional changes; it only simplifies the code.

Instead of maintaining a separate pointer to the backend iff it’s a
`GDelayedSettingsBackend`, just test the `backend` pointer’s type.

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

Helps: #2426
2021-10-26 14:29:31 +01:00
Philip Withnall
0101ccba16 gsettings: Clarify that g_settings_get_child() inherits delay-apply
Previously, the delay-apply status of the parent `GSettings` object
would be partially inherited: `settings->priv->backend` in the child
`GSettings` object would point to a `GDelayedSettingsBackend`, but
`settings->priv->delayed` would be `NULL`.

The expectation from https://bugzilla.gnome.org/show_bug.cgi?id=720891
was that `get_child()` would fully inherit delay-apply status.

So, ensure that `settings->priv->delayed` is correctly set to point to
the delayed backend when constructing any `GSettings`. Update the tests
to work again (presumably the inverted test was an oversight in the
original changes).

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

Fixes: #2426
2021-10-26 14:25:51 +01:00
Philip Withnall
3db22ab8db gsettings: Improve documentation formatting slightly
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-26 14:02:54 +01:00
Philip Withnall
05523b7503 tests: Use a helper macro to drop redundant code in gsettings test
This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-26 13:38:22 +01:00
Philip Withnall
8b443c3556 gdelayedsettingsbackend: Fix applying after calling g_settings_reset()
`g_settings_reset()` changes the value of the setting to `NULL`;
`add_to_tree()` was not handling that correctly.

Add a unit test.

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

Fixes: #2426
2021-10-26 13:38:22 +01:00
Emmanuel Fleury
8444dc5695 Fix cast from pointer to integer of different size warning in gio/gwin32appinfo.c 2021-10-26 11:48:48 +00:00
Marc-André Lureau
b26855579c gio: fix GFile doc indentation and nullable annotations
Add missing (nullable), and use 2-space indentation to avoid markdown
pre-formatted blocks when unwanted.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-10-25 12:57:13 +01:00
Marc-André Lureau
3a6e8bc887 gio: check the given child name is not an absolute path
As this would have undesirable consequence.

Quoting Philip Withnall:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2305#note_1294729:

  The documentation never said anything about accepting absolute paths,
  so any code which is relying on that is relying on undocumented
  behaviour. We’re allowed to change that.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-10-25 12:57:13 +01:00
Marc-André Lureau
1df7c2ea80 gio: document g_file_get_relative_path() with absolute path
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-10-25 12:57:13 +01:00
Philip Withnall
464470dd8f Merge branch '2507-file-enumerator-docs' into 'main'
gfileenumerator: Warn if name is not available for get_child()

Closes #2507

See merge request GNOME/glib!2307
2021-10-21 11:58:32 +00:00
Philip Withnall
b6424b5ce1 gfileenumerator: Warn if name is not available for get_child()
`standard::name` must be available for `g_file_enumerator_get_child()`
to work. Emit a critical warning and return if it’s not. This is similar
to the existing behaviour in `g_file_enumerator_iterate()`.

Improve the documentation to mention this.

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

Fixes: #2507
2021-10-21 12:23:06 +01:00
Philip Withnall
e508a0a8df gfileenumerator: Upgrade existing warning to critical warning
The code cannot function correctly if the `standard::name` attribute is
not present, so upgrade the existing warning to a critical warning and
return if it fails in `g_file_enumerator_iterate()`.

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

Helps: #2507
2021-10-21 12:23:06 +01:00
Philip Withnall
0630272388 gfileenumerator: Add missing precondition to get_child()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2507
2021-10-21 12:23:06 +01:00
Philip Withnall
9b1b04587c gunixmounts: Drop references to pamconsole mount option
It was Red Hat specific when it was introduced in 2004, was never
supported by mount(8) upstream, and was removed entirely in 2008.

It’s confusing for GLib to keep references to it around.

Thanks to Karel Zak for digging up the history of it:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2298#note_1294519

And thanks to Xidorn Quan for looking into it in the first place (see
!2298).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-21 12:22:54 +01:00
Emmanuel Fleury
db5a9d8397 Fix signedness warning in gio/gsocket.c
gio/gsocket.c: In function 'g_socket_get_available_bytes':
gio/gsocket.c:3141:17: warning: comparison of integer expressions of different signedness: 'u_long' {aka 'long unsigned int'} and 'int'
       if (avail == -1)
                 ^~
gio/gsocket.c: In function 'g_socket_send_messages_with_timeout':
gio/gsocket.c:5283:19: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
     for (i = 0; i < num_messages; ++i)
                   ^
gio/gsocket.c:5308:76: warning: operand of ?: changes signedness from 'int' to 'gsize' {aka 'long long unsigned int'} due to unsignedness of other operand
         result = pollable_result == G_POLLABLE_RETURN_OK ? bytes_written : -1;
                                                                            ^~
2021-10-20 17:09:50 +02:00
Emmanuel Fleury
23e9017aff Fix signedness warning in gio/win32/gwinhttpfile.c
gio/win32/gwinhttpfile.c: In function 'g_winhttp_file_query_info':
gio/win32/gwinhttpfile.c:554:13: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long long unsigned int'}
           n == wcslen (content_length))
             ^~
2021-10-19 18:44:38 +02:00
Emmanuel Fleury
a16d6398d7 Fix signedness warning in gio/win32/gwin32fsmonitorutils.c
gio/win32/gwin32fsmonitorutils.c: In function 'g_win32_fs_monitor_handle_event':
gio/win32/gwin32fsmonitorutils.c:107:11: warning: comparison of integer expressions of different signedness: 'GFileMonitorEvent' {aka 'enum <anonymous>'} and 'int'
   if (fme != -1)
           ^~
2021-10-19 18:44:38 +02:00
Emmanuel Fleury
059dc76ae1 Fix signedness warnings in gio/win32/gwinhttpvfs.c
gio/win32/gwinhttpvfs.c: In function 'g_winhttp_vfs_get_file_for_uri':
gio/win32/gwinhttpvfs.c:172:17: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int'
   for (i = 0; i < G_N_ELEMENTS (winhttp_uri_schemes); i++)
                 ^
gio/win32/gwinhttpvfs.c: In function 'g_winhttp_vfs_get_supported_uri_schemes':
gio/win32/gwinhttpvfs.c:210:17: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int'
   for (i = 0; i < G_N_ELEMENTS (winhttp_uri_schemes); i++)
                 ^
2021-10-19 18:44:38 +02:00
Philip Withnall
aa729f0bbf Merge branch 'modern-nm-properties-changed' into 'main'
gio: Stop using deprecated NM PropertiesChanged signal

Closes #2505

See merge request GNOME/glib!2291
2021-10-18 12:15:51 +00:00
Philip Withnall
c8e78f395b Merge branch 'fatal-meson-warnings' into 'main'
meson: fix warnings for extract_all_objects function

See merge request GNOME/glib!2286
2021-10-18 11:57:50 +00:00
Philip Withnall
2423419a29 Merge branch 'static-analysis' into 'main'
fix issues found by svace static code analyzer

See merge request GNOME/glib!2285
2021-10-18 11:03:33 +00:00
Eli Schwartz
abb8e1c3a0 meson: fix warnings for extract_all_objects function
The "recursive:" kwarg is available in the targeted minimum version of
meson, and is basically required if you want to not emit warnings and
maybe error with --fatal-meson-warnings.

There are two basic solutions to this problem:

- The current default behavior is false, so explicitly opt in to that
  value. None of these internal libraries use recursive objects anyway.

- Use link_with to link to the static library directly, rather than the
  extracted objects.

Option 2 is what used to be done before commit
62af03bda8, but it only works with meson
>=0.52 and previously had buggy behavior.

Since the minimum version of meson is now 0.52, it is safe to revert
that commit and go back to using link_with, and therefore option 2 is
chosen.
2021-10-18 11:50:49 +01:00
Egor Bychin
9f1c59eef2 add OOM handling in mimemagic 2021-10-15 14:15:43 +03:00
Egor Bychin
b32727d43d gsocks5proxy: Fix buffer overflow on a really long domain name 2021-10-15 14:15:43 +03:00
Egor Bychin
328bd31631 gsocket: Add ignorant of an fcntl return value 2021-10-15 14:15:43 +03:00
Egor Bychin
cdb9762072 gsettings-mapping: Fix HANDLE being treated as unsigned 2021-10-15 14:15:43 +03:00
Egor Bychin
a50e605d52 gproxyaddressenumerator: Fix string leakage on an invalid input 2021-10-15 14:15:43 +03:00
Egor Bychin
9dc7475f93 gopenuriportal: Fix GVariantBuilder and string leakage on g_open failure 2021-10-15 14:15:38 +03:00
Julian Andres Klode
643fc7ea49 gnetworkmonitornm: Do not re-update cached property
GDBusProxy already takes care of updating the cached property
before emitting the signal, so there is no need to do this
a second time ourselves.
2021-10-12 17:31:42 +02:00
Julian Andres Klode
f419966808 gnetworkmonitornm: Stop using removed PropertiesChanged signal
Use the org.freedesktop.DBus.Properties interface to listen
to PropertiesChanged signals on /org/freedesktop/NetworkManager.

NetworkManager used to provide its own legacy PropertiesChanged
signal, but that was dropped in
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/853

This requires NetworkManager >= 1.2 (2016)

Fixes: #2505
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1946196
2021-10-12 17:22:55 +02:00
Egor Bychin
e90eaff490 gmarshal-internal: Fix string leakage due to misplaced check 2021-10-11 13:59:05 +03:00
Egor Bychin
5a032f32ea glocalfileinfo: Fix atime/mtime mix due to bad copy/paste 2021-10-11 13:56:43 +03:00
Egor Bychin
16ce10eb3c glocalfile: Fix g_stat return value not being checked 2021-10-11 13:55:17 +03:00
Egor Bychin
84affed056 gdbusauthmechanismsha1: Fix pointer being freed after being NULLed 2021-10-11 13:54:07 +03:00
Egor Bychin
36531f7015 gcontenttype: Fix strchr failure leading to a NULL dereference 2021-10-11 13:52:26 +03:00
Simon McVittie
4023c9b567 Merge branch '2500-object-manager-path-validation' into 'main'
gdbusobjectmanagerserver: Disallow child objects at `/`

Closes #2500

See merge request GNOME/glib!2282
2021-10-06 12:03:30 +00:00
Philip Withnall
f0e0754f62 gdbusobjectmanagerserver: Disallow child objects at /
Previously, the code validated that child objects have a path with the
object manager strictly as a prefix. That doesn’t work in the case where
the object manager’s path is `/`. This case is not recommended, but is
supported.

If the object manager’s path is `/`, validate that child objects’ paths
are not equal to it. If they are equal to it, warn the user rather than
emitting a critical warning, since we can’t expect any users who’ve not
been compliant with the spec to instantly rework their D-Bus APIs.

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

Fixes: #2500
2021-10-06 12:34:41 +01:00
Guido Günther
7665b748bb gappinfo: Add launch-started signal
Emit this when we're about to spawn or DBus activate a GAppInfo.  This
allows lauchers to keep the appinfo associated with a startup id.

We use a GVariant to allow for future exansion of the supplied data.
2021-10-04 10:29:08 +02:00
Guido Günther
5890b2bdea gdesktopappinfo: Emit "launched" and "launch-failed" signals for DBus activation too
When using g_desktop_app_info_launch_uris_as_manager the "launched"
signal allows to map a desktop-startup-id to a GAppInfo. Make this
possible for DBus activation too.

Since we don't have a PID there we pass a 0. Update the signal
description accordingly.
2021-10-04 10:29:08 +02:00
Guido Günther
bd7a3e2561 gappinfo: Modernize GAppInfo signals docs a bit
Use type::signal instead of ::signal so gtk-doc can create links and use
`` for variable names and GVariant type string bits.
2021-10-04 10:29:08 +02:00
Philip Withnall
1c37f08004 gdbusobjectmanagerserver: Factor out child object path validation
This introduces no functional changes.

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

Helps: #2500
2021-10-01 10:33:17 +01:00
Philip Withnall
24644208cf giomodule: Skip introspection of two virtual plugin functions
These should be implemented by loadable IO module libraries, but are not
callable in GLib itself.

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

Fixes: #2498
2021-09-29 13:36:04 +01:00
Philip Withnall
36408b119f Merge branch '2404-task-docs-main-context' into 'main'
gtask: Document dependency on GMainContext more explicitly

Closes #2404

See merge request GNOME/glib!2264
2021-09-28 12:47:50 +00:00
Bart Jacobs
1348b36dda g_simply_proxy_resolver_set_ignore_hosts: add missing GIR annotations 2021-09-28 10:24:48 +00:00
Philip Withnall
f31e5e6c66 tests: Re-enable contenttype tests under AddressSanitizer
This is a partial revert of commit
f378352051, as the previous commits have
silenced the AddressSanitizer warnings for `GContentType`.

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

Fixes: #2310
2021-09-27 13:14:00 +01:00
Philip Withnall
c2562bdf58 gcontenttype: Ignore intentional one-time leaks from xdgmime
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2310
2021-09-27 13:13:40 +01:00
Philip Withnall
60173d0a38 Merge branch 'xdgmime_update' into 'main'
Updating xdgmime

See merge request GNOME/glib!2029
2021-09-27 11:50:48 +00:00
Philip Withnall
ef72bed1c0 gtask: Document dependency on GMainContext more explicitly
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2404
2021-09-24 07:57:49 +01:00
Daniel Cheng
2f98cbe483 Remove function pointer casts when calling xdg_run_command_on_dirs().
The function pointer casts silence the compiler and allow the code to
build (and even run in the typical case). However, when building with
control flow integrity checks, the runtime (rightfully) complains about
calling a function via a mismatched function pointer type.
2021-09-23 21:56:21 +02:00