Commit Graph

32247 Commits

Author SHA1 Message Date
Philip Withnall
1e01b5c270 Merge branch 'stdck_intsafe' into 'main'
gtypes: Support more overflow check implementations

See merge request GNOME/glib!4832
2025-09-24 10:05:00 +00:00
Hugo Carvalho
af1e0dff65 Update Portuguese translation 2025-09-24 10:12:08 +01:00
Philip Withnall
11ac1c4ae3 Merge branch 'user-dirs-duplicates' into 'main'
utils: Fix a leak when user-dirs.dirs declares a variable twice

See merge request GNOME/glib!4819
2025-09-24 07:28:00 +00:00
Marco Trevisan
2015c9b2f8 Merge branch 'c23' into 'main'
macros: Add C23/C++23 standards

See merge request GNOME/glib!4831
2025-09-23 21:40:55 +02:00
Tobias Stoeckmann
68e2278bd9 macros: Add C23/C++23 standards
Since C23 and C++23 standards are finalized, add them to list of
possible standards.

While at it, drop 2b and add 2c for next standard to follow.

The C++23 standard version is correctly set with gcc 14 and
newer, so keep that in mind in tests for older versions.
2025-09-23 20:57:36 +02:00
Tobias Stoeckmann
03bab2805c gtypes: use intsafe.h as fallback if available
Windows systems have the intsafe.h header, defining optimized
overflow checks for the platform. Since the Visual Studio compiler
lacks support for __builtin overflow check macros and also has no C23
support as of version 19, use intsafe.h to still have fast overflow
checks.
2025-09-23 19:43:42 +02:00
Tobias Stoeckmann
609a8885ef gtypes: Use stdckdint.h if possible
The ckd_add/ckd_mul functionality has been introduced with C23. Use
it for overflow checks if it is available. If not, fall back
to __builtin macros. If these are not available either, fall back to
custom code.
2025-09-23 19:34:02 +02:00
Michael Catanzaro
844fb89628 Merge branch 'giowin32-uninit' into 'main'
giowin32: Fix uninitialised variable error on msys2-clang64

See merge request GNOME/glib!4830
2025-09-23 10:32:09 -05:00
Philip Withnall
2414ca69d2 giowin32: Fix uninitialised variable error on msys2-clang64
I guess a compiler upgrade on msys2 has happened, because this wasn’t a
problem before, and the code hasn’t changed.

Fixes the warning:
```
../glib/giowin32.c:1828:47: error: variable 'c' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer]
 1828 |   channel->is_writeable = WriteFile (handle, &c, 0, &count, NULL);
      |                                               ^
1 error generated.
```

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-09-23 16:09:38 +01:00
Philip Withnall
2eb853a40d Merge branch 'win_typos' into 'main'
docs: Fix typos in win32-build.md

See merge request GNOME/glib!4829
2025-09-23 14:43:25 +00:00
Tobias Stoeckmann
5285c18b88 docs: Fix typos in win32-build.md
Fixed some grammar typos.

While "continue to use" is correct, "continue using" is a better
fitting form in this context.
2025-09-23 13:45:24 +02:00
Philip Withnall
3c16bc92af Merge branch 'ghostutils_ascii' into 'main'
ghostutils: Treat 0x80 (and above) as non-ASCII

See merge request GNOME/glib!4827
2025-09-22 16:36:52 +00:00
Tobias Stoeckmann
a4a32bbeaa 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 17:57:50 +02:00
Marco Trevisan
ed36f4c642 Merge branch 'wip/suppress-missing-lock-coverity' into 'main'
gdbus-codegen: Supress coverity warning in skeleton finalization

See merge request GNOME/glib!4825
2025-09-21 13:35:26 +02:00
Carlos Garnacho
592082ef1d gdbus-codegen: Supress coverity warning in skeleton finalization
This commit has the potential to close a thousand Coverity issues.
On generated code from gdbus-codegen, Coverity typically warns on
skeleton->priv->changed_properties_idle_source happening outside
the skeleketon->priv->lock during finalize(), while it's protected
by this mutex in other parts.

Presumably if the object is in finalization, there should be no
other threads poking at it, so the code is actually safe for the
intended use and the warning moot.

To address this, change gdbus-codegen to prefer g_clear_pointer()
with glib >= 2.38 (should be most often the case nowadays) so this
access is reserved to a single line of code, and mark this line of
code with a Coverity code annotation in order to suppress the
warning.
2025-09-21 12:02:58 +02:00
Philip Withnall
d6b160e443 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-19 16:53:43 +01:00
Philip Withnall
bd3418647c 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-19 16:53:39 +01:00
Philip Withnall
1c32cad71b 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-19 16:53:34 +01:00
Philip Withnall
38dac960c7 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-19 16:53:30 +01:00
Philip Withnall
474b90d4ff 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-19 16:53:26 +01:00
Philip Withnall
f7fca2e9b6 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-19 16:53:21 +01:00
Philip Withnall
2258775871 tests: Rename a couple of tests for consistency
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-09-19 16:53:17 +01:00
Philip Withnall
f70ed97806 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-19 16:53:12 +01:00
Philip Withnall
e04e8cac51 Merge branch 'wip/smcv/debbug1115617' into 'main'
gio/tests: Fix a race condition in /gdbus/connection/flush

See merge request GNOME/glib!4820
2025-09-19 13:49:54 +00:00
Philip Withnall
fe1c1222f8 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-19 13:51:32 +01:00
Simon McVittie
67dc482f8a 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 13:44:37 +01:00
Simon McVittie
73224802b3 gio/tests: Convert the time to wait for expected signal into a constant
No functional change.

Signed-off-by: Simon McVittie <smcv@debian.org>
2025-09-19 13:44:30 +01:00
Simon McVittie
0960e72b07 gio/tests: Avoid a race condition
We have two things happening in parallel:

1. The GDBus worker thread writes out an AddMatch call to the socket,
   the message bus reads that method call from the other end of the
   socket, and the message bus responds by adding the match rule
   for the signal subscription

2. The main thread forks, and the child execs
   gdbus-connection-flush-helper, which sends the signal that we are
   expecting; the message bus receives that signal, and broadcasts it
   to subscribers, if any

Normally (1.) wins the race because exec'ing a child process is more
time-consuming than IPC, and the test passes.

However, it is possible for (2.) to win the race. If so, we will never
receive the expected signal (because it was received by the message bus
before the AddMatch() method call, so at the time it was received, the
test was not yet a subscriber); the test waits until the timeout and
then gives up, and the test fails.

For whatever reason, Debian's s390x buildd seems to be reliably failing
this test since this week, having previously passed. I don't know what
changed. I can (very rarely) reproduce the race condition described
above on a developer-accessible s390x machine by repeatedly running the
/gdbus/connection/flush test in a loop.

Bug-Debian: https://bugs.debian.org/1115617
Signed-off-by: Simon McVittie <smcv@debian.org>
2025-09-19 13:44:23 +01:00
Simon McVittie
ac7275b185 gio/tests: Factor out connection_wait_for_bus() from gdbus-subscribe
Signed-off-by: Simon McVittie <smcv@debian.org>
2025-09-19 13:44:05 +01:00
Philip Withnall
4f07891f1f Merge branch 'strfuncs_join_oob' into 'main'
strfuncs: Check for overflows when joining strings

See merge request GNOME/glib!4816
2025-09-18 15:51:31 +00:00
Philip Withnall
68c4b3b45c Merge branch 'fix_3785' into 'main'
gio-tool-trash: Report error when emptying the trash

Closes #3785

See merge request GNOME/glib!4818
2025-09-18 15:11:47 +00:00
Lukáš Tyrychtr
4ab0357974 gio-tool-trash: Report error when emptying the trash
This adds error reporting and proper exit code when emptying the trash fails
for some (mainly permission) related error.

Fixes #3785.
2025-09-18 15:11:47 +00:00
Tobias Stoeckmann
3719ac8db7 strfuncs: Check for overflows when joining strings
The functions g_strconcat, g_strjoinv and g_strjoin perform the
concatination of strings in two phases. The first phase figures out the
required amount of memory to hold the resulting string. The second
phase actually copies the strings into the allocated memory.

If the sum of the lengths of all strings to be joined exceeds G_SIZEMAX,
then phase two triggers an out of boundary write due to insufficient
amount of memory allocated.

While this sounds impossible to do at first, actually it becomes a
possibility on 32 bit systems with merely 20 MB of heap. The overflow
can actually happen if the same string is joined multiple times. See
attached unit test. While the same can be done with 64 bit systems, it
takes much more memory and a lot of time.

Fortunately the protection is rather cheap, although it adds two or
three machine instructions and branches due to testing.
2025-09-18 17:00:28 +02:00
Philip Withnall
d67aa209e2 Merge branch 'constructor-annotations' into 'main'
Mark a couple of functions as constructors and not methods

See merge request GNOME/glib!4817
2025-09-18 11:53:50 +00:00
Sebastian Dröge
a6727dfde8 Mark a couple of functions as constructors and not methods 2025-09-18 11:13:48 +03:00
Philip Withnall
9428157e08 Merge branch 'unicode17' into 'main'
gunicode: Update the code for Unicode 17.0.0

See merge request GNOME/glib!4793
2025-09-17 10:53:10 +00:00
Philip Withnall
b961111c97 gfile: Expand documentation around file equality
Prompted by
https://discourse.gnome.org/t/help-on-g-file-equal-and-g-file-attribute-id-file/31268/5.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-09-17 10:51:31 +01:00
Peng Wu
4dace3e026 gunicode: Update to Unicode 17.0.0
All changes mechanically generated with:
```
./tools/update-unicode-data.sh ~/Downloads/UCD 17.0.0
```
using the data from https://www.unicode.org/Public/17.0.0/ucd/UCD.zip.

Signed-off-by: Peng Wu <pwu@redhat.com>
2025-09-17 10:25:40 +01:00
Peng Wu
a211ea641a gunicode: Update the test case for Unicode 17.0.0 2025-09-17 10:25:40 +01:00
Peng Wu
cc85da3134 gunicode: Add some scripts and line break for Unicode 17.0.0
Co-authored-by: Philip Withnall <philip@tecnocode.co.uk>
2025-09-17 10:25:40 +01:00
Philip Withnall
edcd318f21 Merge branch 'glist-gslist-nullable-param-docs' into 'main'
Add missing "nullable" to parameter docs of GList/GSList

See merge request GNOME/glib!4807
2025-09-17 09:20:49 +00:00
Philip Withnall
86cd3cc097 Merge branch 'update-sr-translation' into 'main'
Update Serbian translation

See merge request GNOME/glib!4813
2025-09-17 08:05:44 +00:00
Philip Withnall
b7e4751b62 Merge branch 'main' into 'main'
Update Esperanto translation

See merge request GNOME/glib!4811
2025-09-17 08:03:02 +00:00
Kristjan ESPERANTO
066631e25d Update Esperanto translation 2025-09-17 08:02:17 +02:00
Marco Trevisan
290839a3b8 Merge branch 'gutils_unlocked' into 'main'
gutils: Mark load_user_special_dirs unlocked

See merge request GNOME/glib!4810
2025-09-17 00:07:42 +02:00
Милош Поповић
dd79c0f8a5 Update Serbian translation 2025-09-16 23:28:38 +02:00
Tobias Stoeckmann
1daef51682 gutils: Fix file name in comment
The implementation can be found in gosxutils.m.
2025-09-16 19:26:09 +02:00
Tobias Stoeckmann
2515357d79 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-16 19:26:06 +02:00
Michael Catanzaro
355996f241 Merge branch 'gutils_special_dirs_leak' into 'main'
gutils: Handle singletons in unlocked functions

Closes #3784

See merge request GNOME/glib!4808
2025-09-16 11:21:53 -05:00
Philip Withnall
1d37756f64 Merge branch 'ghash_size_uint' into 'main'
ghash: Fix data type related issues

Closes #672

See merge request GNOME/glib!4783
2025-09-16 16:14:41 +00:00