Commit Graph

32179 Commits

Author SHA1 Message Date
Philip Withnall
7e5489cb92 fuzzing: Add fuzz tests for g_filename_{to,from}_uri()
These functions could be called on untrusted input data, and since they
do URI escaping/unescaping, they have non-trivial string handling code.

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

See: #3827
2025-11-21 13:37:22 +00:00
Philip Withnall
9bcd65ba5f gconvert: Error out if g_escape_uri_string() would overflow
If the string to escape contains a very large number of unacceptable
characters (which would need escaping), the calculation of the length of
the escaped string could overflow, leading to a potential write off the
end of the newly allocated string.

In addition to that, the number of unacceptable characters was counted
in a signed integer, which would overflow to become negative, making it
easier for an attacker to craft an input string which would cause an
out-of-bounds write.

Fix that by validating the allocation length, and using an unsigned
integer to count the number of unacceptable characters.

Spotted by treeplus. Thanks to the Sovereign Tech Resilience programme
from the Sovereign Tech Agency. ID: #YWH-PGM9867-134

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

Fixes: #3827

Backport 2.86: Changed the translatable error message to re-use an
existing translatable string, to avoid adding new translatable strings
to a stable branch. The re-used string doesn’t perfectly match the
error, but it’s good enough given that no users will ever see it.
2025-11-21 13:36:11 +00:00
Luca Bacci
025b3f3a33 Merge branch 'backport-4901-win32-file-monitor-hard-links-glib-2-86' into 'glib-2-86'
Backport !4901 “Issue #3819: G_FILE_MONITOR_WATCH_HARD_LINK does not monitor files on Windows.” to glib-2-86

See merge request GNOME/glib!4912
2025-11-20 21:38:22 +01:00
Jehan
d3a16bc03c Issue #3819: G_FILE_MONITOR_WATCH_HARD_LINK does not monitor files on Windows.
Current code was clearly considering the case of having only a filename
as a directory monitoring, instead of a hard-link monitoring. As I
assume that hard links don't exist on Windows, this case should simply
revert back to the basic file monitoring code path.
2025-11-20 15:47:45 +00:00
Philip Withnall
421fa1c9ad 2.86.2
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2.86.2
2025-11-18 16:59:09 +00:00
Philip Withnall
83e6ea7791 Merge branch 'backport-4860-memory-monitor-solaris-glib-2-86' into 'glib-2-86'
Backport !4860 “Fix g_memory_monitor_base_query_mem_ratio on Solaris” to glib-2-86

See merge request GNOME/glib!4889
2025-10-31 14:12:39 +00:00
Alan Coopersmith
6cbbaa653e 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-31 13:19:40 +00:00
Alan Coopersmith
94d5369d9a build: avoid sysinfo() on Solaris
Solaris inherited the SVR4 sysinfo() function, which takes a different
number of arguments from Linux, and provides information such as host
name and OS version, but not information on free or total memory.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2025-10-31 13:19:26 +00:00
Marco Trevisan
61384f791d Merge branch 'backport-4886-utils-trailing-slashes-glib-2-86' into 'glib-2-86'
Backport !4886 “gutils: Strip all trailing slashes” to glib-2-86

See merge request GNOME/glib!4890
2025-10-28 23:22:31 +01:00
Tobias Stoeckmann
bb23a0e8cb gutils: Strip all trailing slashes
The code stripped all but the first trailing slash in order to handle
the absolute root path "/". This breaks the removal of trailing slashes
for paths starting with $HOME, though.

Fix the logic to remove all trailing slashes if $HOME is encountered.

Closes #3811
2025-10-28 21:50:01 +00:00
Marco Trevisan
5d14c89993 Merge branch 'backport-4884-regex-fix-glib-2-86' into 'glib-2-86'
Backport !4884 “gregex: Handle PCRE2_ERROR_MISSING_NUMBER_TERMINATOR if defined” to glib-2-86

See merge request GNOME/glib!4888
2025-10-27 23:44:57 +01:00
Marco Trevisan (Treviño)
c95a7be124 tests/regex: Add the error messages to tests
It can be useful for debugging purposes
2025-10-27 21:22:10 +00:00
Marco Trevisan (Treviño)
9f47e1c16f gregex: Handle PCRE2_ERROR_MISSING_NUMBER_TERMINATOR if defined
When the error is defined in a new enough PCRE2 we should handle it.

However let's not define an error message for this in this commit (just
let's use the old one that is generic enough), so that it can be backported
to stable versions without having to require new translations.

Closes: #3809
2025-10-27 21:22:10 +00:00
Nick Wilson
183bccc4c9 glib/tests/regex: Add a future-proof test case for missing back reference
This test applies to both old and newer versions of PCRE2 where
back reference error has now increased the granularity and is referred
as PCRE2_ERROR_MISSING_NUMBER_TERMINATOR instead.

Co-Authored-By: Marco Trevisan <mail@3v1n0.net>
2025-10-27 21:22:10 +00:00
Michael Catanzaro
805cb101ed Merge branch 'mcatanzaro/4877-backport' into 'glib-2-86'
Backport "gresolver: Fix loopback detection of IPv6 addresses"

See merge request GNOME/glib!4878
2025-10-22 14:24:02 -05:00
Patrick Griffis
90c29b7fb2 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 16:20:45 -05:00
Philip Withnall
7b2afbd420 2.86.1
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2.86.1
2025-10-21 15:26:53 +01:00
Michael Catanzaro
b97228a7c7 Merge branch 'backport-4871-netlink-notify-connectivity-glib-2-86' into 'glib-2-86'
Backport !4871 “gnetworkmonitorbase: Add missing notify::connectivity signal” to glib-2-86

See merge request GNOME/glib!4873
2025-10-20 17:36:08 -05:00
Philip Withnall
9fa7f4cc7d Merge branch 'backport-4859-appinfo-portal-crash-glib-2-86' into 'glib-2-86'
Backport !4859 “gopenuriportal: Fix a crash when the file can’t be opened” to glib-2-86

See merge request GNOME/glib!4865
2025-10-20 22:04:20 +00:00
Philip Withnall
d80a4795c8 Merge branch 'backport-4792-add-back-type-refs-glib-2-86' into 'glib-2-86'
Backport !4792 “gtype: Use transfer none for types (un)ref functions” to glib-2-86

See merge request GNOME/glib!4867
2025-10-20 21:38:27 +00:00
Philip Withnall
9373f55278 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 21:54:36 +01:00
Philip Withnall
7a9a382149 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-20 21:45:37 +01:00
Marco Trevisan (Treviño)
f9a5848cf1 gtype: Use transfer none for types (un)ref functions
We have some (deprecated) methods that technically still return
transfer-full instances of GTypeClass's and GTypeInterface's.

The introspection scanner cannot generate bindings for them though since
it does not know how to manage their lifecycle, and we end up skipping
these symbols.

This is breaking some language bindings, and in particular gjs [1] and
lua-lgi, that were using the .ref methods.

While we should not use deprecated functions in the language bindings,
these symbols should still be introspected.

[1] https://gitlab.gnome.org/GNOME/gjs/-/issues/711

Partially reverts commit cad84d5e27.
2025-10-20 20:45:26 +00:00
Michael Catanzaro
edda8a6a9a Merge branch 'backport-4870-4868-ci-fixes-glib-2-86' into 'glib-2-86'
Fix macOS and msys2 CI builds on glib-2-86 branch

See merge request GNOME/glib!4872
2025-10-20 15:14:50 -05:00
René de Hesselle
954ac5f36f ci: Setup ramdisk for temp dir redirection
This step is no longer "hidden away in the infrastructure" but now in
the open.

Background: some GLib tests can fail with timeouts because of some
assumptions regarding the temporary directory that don't work out on
macOS. Until this is properly investigated and resolved, the
workaround is to redirect it to a ramdisk.

Also add ORKA_RUNNER variable as the macOS CI infrastructure evolves.
Future changes to the image can be controlled this way.

Fixes https://gitlab.gnome.org/Infrastructure/Infrastructure/-/issues/2091
2025-10-20 16:34:44 +01:00
Luca Bacci
a0fad794df CI/MSYS2: Set GitLab submodule strategy to recursive
Workaround for #3715
2025-10-20 16:34:44 +01:00
Philip Withnall
344fceba86 Merge branch 'glib-2-86' into 'glib-2-86'
Update British English translation (2.86)

See merge request GNOME/glib!4848
2025-10-02 14:55:51 +00:00
Bruce Cowan
0574833f42 Update British English translation 2025-10-02 15:34:29 +01:00
Philip Withnall
22068cf72f Merge branch 'cherry-pick-d632c3ab' into 'glib-2-86'
Backport "girnode: Fix computation of union member offsets" to glib-2-86

See merge request GNOME/glib!4842
2025-09-30 16:34:05 +00:00
Philip Chimento
ecbf92a586 girnode: Fix computation of union member offsets
Regression from 501ff95c. Union member offsets are always 0, but we need
to mark them as 'COMPUTED' otherwise they are not written to the
typelib, which results in gi_field_info_get_offset() returning 0xffff.

Since gi_field_info_get/set_field() cannot check that the offset is
within the size of the struct or union, that means poking into invalid
memory addresses.

This also adds some basic tests for GIFieldInfo which would have caught
this bug.

Closes: #3745
2025-09-30 16:36:40 +01:00
Philip Withnall
091b7cdd93 Merge branch 'glib-2-86' into 'glib-2-86'
Update Romanian translation

See merge request GNOME/glib!4839
2025-09-30 15:27:59 +00:00
Antonio Marin
6fa4379cdb Update Romanian translation 2025-09-27 09:40:46 +00:00
Michael Catanzaro
5713425544 Merge branch 'backport-4835-pt-translation-glib-2-86' into 'glib-2-86'
Backport !4835 “Update Portuguese translation” to glib-2-86

See merge request GNOME/glib!4836
2025-09-24 11:13:06 -05:00
Michael Catanzaro
f455ae72ee Merge branch 'backport-4810-4819-user-dirs-duplicates-glib-2-86' into 'glib-2-86'
Backport !4810 and !4819, various fixes to user-dirs.dirs handling in gutils

See merge request GNOME/glib!4834
2025-09-24 11:10:46 -05:00
Hugo Carvalho
500f836370 Update Portuguese translation 2025-09-24 11:09:58 +01:00
Philip Withnall
25dd814ed8 tests: Add a test for g_reload_user_special_dirs_cache()
This test specifically checks whether the documented behaviour of
deliberately leaking old special dirs strings (which might still be
pointed to in user code) works.

I haven’t gone back and used this new unit test with an older version of
GLib, but I suspect the ‘deliberate leak’ code hasn’t worked for a
while. See the changes in the previous few commits, which were necessary
to get this unit test to pass.

The previous `test_user_special_dirs()` test has been deleted, as what
it was testing has been entirely subsumed into the new test.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-09-24 08:38:59 +01:00
Philip Withnall
fa1ed222e2 tests: Factor out a helper function in the utils tests
This introduces no functional changes, it just factors out a helper to
set a mock `user-dirs.dirs` file, so that we can do the same in multiple
tests.

It does add a little more error checking to the helper code though; in
particular it checks that the test is running with
`G_TEST_OPTION_ISOLATE_DIRS`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-09-24 08:38:54 +01:00
Philip Withnall
964c3f1069 gutils: Move the special case default value for G_USER_DIRECTORY_DESKTOP
Otherwise it isn’t set on every code path, and it’s possible for a
caller to receive `NULL` when they call `g_get_user_special_dir
(G_USER_DIRECTORY_DESKTOP)`, i.e. after calling
`g_reload_user_special_dirs_cache()`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-09-24 08:38:50 +01:00
Philip Withnall
ab09a3e933 gutils: Fix deliberate-leak code in g_reload_user_special_dirs_cache()
It seems it wasn’t behaving as advertised: it was freeing all the old
string values unless they were strcmp-equal to the new ones, in which
case the new ones were discarded.

What’s actually documented is that the old values are always leaked,
unless they’re strcmp-equal to the new ones.

Adjust the code to match the documentation. A unit test will be added in
a following commit.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-09-24 08:38:45 +01:00
Philip Withnall
e4c2b08218 gutils: Fix a leak when user-dirs.dirs declares a variable twice
Found by the oss-fuzz test for this parser,
`fuzzing/fuzz_special_dirs.c`.

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

oss-fuzz#445870121
oss-fuzz#445848222
2025-09-24 08:38:41 +01:00
Philip Withnall
888415030e tests: Fix a minor leak in the utils test
Found with `meson test --setup valgrind`, although I also had to change
relevant lines in `glib/tests/meson.build` temporarily to avoid the
other tests in the file taking forever:
```
  'utils' : {
    'c_standards': c_standards.keys(),
    'args': ['-p', '/utils/user-special-dirs'],
  },
```

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-09-24 08:38:36 +01:00
Philip Withnall
0a0da8b21a tests: Rename a couple of tests for consistency
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-09-24 08:38:32 +01:00
Philip Withnall
66aee5e2c8 tests: Move user-special-dirs test from utils-isolated.c to utils.c
`utils-isolated.c` is meant for testing the behaviour of
`G_TEST_OPTION_ISOLATE_DIRS`, not testing the general behaviour of
`gutils.c`. My mistake for not noticing this at code review time when
the test was added.

This introduces no functional changes, just moves a test around.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-09-24 08:38:28 +01:00
Philip Withnall
133aed1875 tests: Use G_TEST_OPTION_ISOLATE_DIRS for utils tests
Another test isolated.

This does mean moving one of the test cases from the suite out into a
separate suite, as it explicitly relies on running without
`G_TEST_OPTION_ISOLATE_DIRS`, and I think that makes sense. The other
test cases run fine when isolated.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-09-24 08:38:23 +01:00
Tobias Stoeckmann
d30730bc71 gutils: Fix file name in comment
The implementation can be found in gosxutils.m.
2025-09-24 08:38:18 +01:00
Tobias Stoeckmann
3d7caa9407 gutils: Mark load_user_special_dirs unlocked
The load_user_special_dirs function performs no internal locking, which
means that callers must already hold the g_utils_global lock. Since we
mark some getters as unlocked by now, do the same with
load_user_special_dirs to highlight this additional requirement.

Suggested by Michael Catanzaro
2025-09-24 08:38:12 +01:00
Michael Catanzaro
4df37832d9 Merge branch 'backport-4827-hostutils-non-ascii-glib-2-86' into 'glib-2-86'
Backport !4827 “ghostutils: Treat 0x80 (and above) as non-ASCII” to glib-2-86

See merge request GNOME/glib!4828
2025-09-22 16:42:07 -05:00
Tobias Stoeckmann
e56606de3d ghostutils: Treat 0x80 (and above) as non-ASCII
Any ASCII character above 0x7F should be treated as UTF-8 in
ghostutils functions because GLib expects host names to be either
punycode encoded or in valid UTF-8 format.

The checks in gutf8.c already treat 0x80 as non-ASCII, but two checks
in ghostutils.c erroneously check for "great than" not "greater than or
equal to".

Clarify this by adding a new macro which is reused by PUNICODE_IS_BASIC
for better documentation in code.
2025-09-22 18:04:07 +01:00
Philip Withnall
b055af41d0 Merge branch 'backport-4820-gdbus-test-race-glib-2-86' into 'glib-2-86'
Backport !4820 “gio/tests: Fix a race condition in /gdbus/connection/flush” to glib-2-86

See merge request GNOME/glib!4821
2025-09-19 17:29:01 +00:00
Simon McVittie
209dff23f1 gio/tests: Wait up to 10 seconds for a signal to be received
If the build/test machine is slow, heavily-loaded or otherwise
inconvenienced, it might take a few seconds for the signal to be sent
by the subprocess, received by the message bus, re-broadcasted by the
message bus and received by the test code. Wait a few more seconds
before giving up.

If this test is successful, increasing this timeout will not slow it
down: we stop waiting for the signal as soon as we receive it. This will
only make any difference if the test would have failed.

Signed-off-by: Simon McVittie <smcv@debian.org>
2025-09-19 16:55:55 +01:00