Commit Graph

24418 Commits

Author SHA1 Message Date
Philip Withnall
cdda7bb59a Revert "Merge branch 'fix-windows-pc' into 'main'"
This reverts merge request !2459
2022-01-27 13:04:12 +00:00
Hugo Carvalho
73aebf3887 Update Portuguese translation 2022-01-27 12:53:46 +00: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
f242299b3e Merge branch 'windows-static-resource' into 'main'
Windows: Do not link DLL specific resources when doing a static build

Closes #2585

See merge request GNOME/glib!2457
2022-01-27 11:02:34 +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
Sebastian Dröge
13ee46538f Merge branch 'fix-g_find_program_in_path' into 'main'
gutils: Fix g_find_program_in_path() to return an absolute path

Closes #2586

See merge request GNOME/glib!2460
2022-01-27 10:50:36 +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
Christoph Niethammer
78dc1cc3cd gutils: Fix g_find_program_in_path() to return an absolute path
Fix a possibility of returning a relative path, in case PATH contains
a relative path. According to the doc, the function should return an
absolute path.

Signed-off-by: Christoph Niethammer <christoph.niethammer@gmail.com>
2022-01-27 03:54:01 +01:00
Leônidas Araújo
4d97fef04c Update Brazilian Portuguese translation 2022-01-26 19:29:01 +00:00
Rafael Fontenelle
2e4eccb872 Update Brazilian Portuguese translation
(cherry picked from commit 22e9237d02)
2022-01-26 19:22:41 +00:00
Fran Dieguez
d36390778b Update Galician translation 2022-01-26 18:47:41 +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
Hugo Carvalho
34458a7f2a Update Portuguese translation 2022-01-26 15:47:11 +00: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
bb4bec0921 gmessages: Expose a property for enabling debug message output
This is an API analogue of the G_MESSAGES_DEBUG environment variable. It
is intended to be exposed outside applications (for example, as a D-Bus
interface — see follow-up commits) so that there is a uniform interface
for controlling the debug output of an application.

Helps: #1190
2022-01-26 15:17:02 +00:00
Philip Withnall
70c116e602 Merge branch 'win32-afunix' into 'main'
gio: Add some AF_UNIX support on Windows

Closes #2487

See merge request GNOME/glib!2445
2022-01-26 15:11:48 +00:00
Xavier Claessens
9159e84ce5 Windows: Do not link DLL specific resources when doing a static build
Fixes: #2585
2022-01-26 09:49:30 -05: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
Hugo Carvalho
51e6e4fc2f Update Portuguese translation 2022-01-26 14:28:38 +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
Marc-André Lureau
fd1e2c8019 meson: check for win32 afunix.h
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:23 +04:00
Philip Withnall
34bd3fc5cc Merge branch 'security-fixes-main' into 'main'
gdbusmessage, gvariant and garray fixes

Closes #2557, #2572, and #2578

See merge request GNOME/glib!2454
2022-01-26 13:39:37 +00:00
Tobias Stoeckmann
374a1895b6 garray: Fix integer overflows in element capacity calculations
Integer overflows in size calculations of buffers (GArray and GPtrArray)
allow subsequent buffer overflows. This happens due to conversions
between gsize and guint.

Proof of concept demonstrations of the overflows can be found in issue
2578. They are not being added as unit tests as they require too much
memory to test.

This will affect `GArray`s which are 4GB in size, or `GPtrArray`s which
are 48GB in size.

Fixes: #2578
2022-01-26 13:06:26 +00: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
Sebastian Wilhelmi
77233f6f07 gvariant-serialiser: Prevent unbounded recursion in is_normal()
This fixes a bug in 7c4e6e9fbe.

The original approach in that commit accidentally only checked the depth
at the leaf nodes in the variant tree, whereas actually the depth should
be checked before recursing to avoid stack overflow.

It neglected to consider that `g_variant_serialised_is_normal()` would
be recursed into by some of the `DISPATCH(_is_normal)` cases. When that
happened, the depth check was after the recursion so couldn’t prevent a
stack overflow.

Fixes: #2572
2022-01-26 13:04:49 +00:00
Philip Withnall
5ca038cf57 Merge branch 'windows-static-build-core' into 'main'
Enable full-static build on Windows

Closes #692

See merge request GNOME/glib!2438
2022-01-26 11:38:44 +00:00
Loïc Le Page
097cd3a16b Add Windows native static build using msvc to CI 2022-01-26 12:07:46 +01: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
Loic Le Page
2ff2c9eb5b Refactor glib/glib-init.c to isolate init/deinit steps in isolated functions 2022-01-26 10:08:20 +01:00
Loic Le Page
4fdbfcc9b7 Uniformize G_PLATFORM_WIN32 and G_OS_WIN32 in glib-init.c
According to build system (meson.build file), G_PLATFORM_WIN32 and G_OS_WIN32
are synonym. This commit just unify the usage of this define to prepare
for the static build conditional compilation code.
2022-01-26 10:08:20 +01:00
Loic Le Page
98880b9f99 Add license disclaimer and header guards to gconstructor.h 2022-01-26 10:08:20 +01:00
Loic Le Page
bfa46bd98a Fix gconstructor.h header to include gslist functions
Macros defined in gconstructor.h header are using g_slist_find()
function but the gslist.h corresponding header was not included.
2022-01-26 10:08:20 +01:00
Kukuh Syafaat
71d2b66f34 Update Indonesian translation 2022-01-26 01:51:36 +00:00
Philip Withnall
01628f95b5 Merge branch 'random-fixes' into 'main'
Reduce the amount of compile-time warnings

See merge request GNOME/glib!2441
2022-01-25 19:45:03 +00:00
Pablo Correa Gómez
6406217f50
gsequence: Fix variable maybe uninitialized warning
../glib/gsequence.c: In function 'g_sequence_move_range':
../glib/gsequence.c:640:24: warning:
 'dest_seq' may be used uninitialized in this function [-Wmaybe-uninitialized]
  640 |   if (dest && dest_seq == src_seq &&
      |               ~~~~~~~~~^~~~~~~~~~
2022-01-25 20:18:41 +01:00
Pablo Correa Gómez
c2ff12ced5
glib/tests: Fix variable maybe uninitialized warning 2022-01-25 20:18:41 +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