1
0
mirror of https://gitlab.gnome.org/GNOME/glib.git synced 2026-10-24 00:49:00 +03:00

33020 Commits

Author SHA1 Message Date
Philip Withnall
00648e21e9 2.89.0
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2.89.0
2026-05-20 19:29:08 +01:00
Philip Withnall
3a0ee9a1c4 Merge branch 'gbyte_array_enhance_maybe_expand' into 'main'
Improve performance of g_array_maybe_expand()

See merge request GNOME/glib!5188
2026-05-20 13:40:59 +00:00
Elbehery
59e73e5108 garray: enhance g_array_maybe_expand performance
Avoid division operation every time g_array_maybe_expand
is called, and instead cached max_len value.
2026-05-20 16:20:41 +03:00
Philip Withnall
db85064970 Merge branch 'fix-msvc-arm64-ci' into 'main'
MSVC CI: Use the 10.0.22621.0 Windows SDK for ARM64

Closes #3958

See merge request GNOME/glib!5189
2026-05-20 12:37:48 +00:00
Chun-wei Fan
59d105dfb6 MSVC CI: Use the 10.0.22621.0 Windows SDK for ARM64
Visual Studio 2019 does not work with the 10.0.26100.0 or later SDKs for
ARM64 builds, so downgrade to the 10.0.22621.0 SDK for ARM64 builds,
which should be still present.

Fixes: #3958.
2026-05-20 10:24:23 +08:00
Philip Withnall
8572e1e4aa Merge branch 'docs/fix-g-ascii-strtod-description' into 'main'
gstrfuncs: fix g_ascii_strtod() underflow docs to match C99/C11

Closes #2173

See merge request GNOME/glib!5151
2026-05-19 17:14:36 +00:00
depuc8
ae7895ad15 gstrfuncs: fix g_ascii_strtod() underflow docs to match C99/C11
The previous documentation stated: "If the correct value would cause
underflow, zero is returned and ERANGE is stored in errno." This was
copied verbatim from the ANSI C standard and is no longer accurate
under C99/C11.
C99/C11 only guarantees that the returned value's magnitude is no
greater than the smallest normalised positive number. Subnormal
(gradual underflow) results are permitted and zero is not required.
Additionally, whether ERANGE is set for gradual underflow is
implementation-defined — it may not be set when a subnormal value
is returned, even though errno is still reset before the call.
Add tests to verify the updated behaviour.

Closes #2173
2026-05-19 22:27:26 +05:30
Philip Withnall
4ff34a15bc Merge branch 'wip/chergert/g_set_strv' into 'main'
strfuncs: add g_set_strv()

Closes #3907

See merge request GNOME/glib!5095
2026-05-19 13:43:17 +00:00
Christian Hergert
fd3b35769e strfuncs: add g_set_strv() and g_set_strv_take()
This adds a new g_set_strv() that has been used in various GNOME projects
to help ensure that strv properties are changed with minimal notify()
emissions as well as reduce chances for UAF.

Additionally, g_set_strv_take() is provided to allow setting a GStrv
without making a copy of the provided string. Use this when you are
using API like g_strv_builder_end().

Fixes: #3907
2026-05-19 15:24:25 +02:00
Philip Withnall
2bdd8c34a1 Merge branch 'fix-mixed-shared-static-builds' into 'main'
Meson: Don't hardcode FFI_STATIC_BUILD / G_INTL_STATIC_COMPILATION

See merge request GNOME/glib!5182
2026-05-19 13:16:24 +00:00
Philip Withnall
41a3579732 Merge branch 'feature/trash-macos' into 'main'
gio: use NSFileManager for trash on macOS

Closes #1161 and #3069

See merge request GNOME/glib!5143
2026-05-19 13:01:49 +00:00
Philip Withnall
747d8b3100 Merge branch 'mcatanzaro/shell-quote-docs' into 'main'
Add safety documentation regarding use of g_shell_quote()

See merge request GNOME/glib!5187
2026-05-19 12:36:25 +00:00
Michael Catanzaro
4b77d68d3d Add safety documentation regarding use of g_shell_quote()
Failure to call g_shell_quote() where required can be a serious problem
(see CWE-77 and CWE-88), so let's draw special attention to when you
need this function.
2026-05-19 12:36:25 +00:00
Byoungchan Lee
9cd1eea425 gio: suppress deprecated UTI warnings on macOS 2026-05-19 12:36:18 +00:00
Byoungchan Lee
35ecf4c5ec gio: use NSFileManager for trash on macOS 2026-05-19 12:36:18 +00:00
Luca Bacci
279ed5e22f Meson: Don't hardcode FFI_STATIC_BUILD / G_INTL_STATIC_COMPILATION
The defines must come from subprojects or .pc files. We might
build GLib statically and libffi / proxy-libintl as shared
libraries.

See https://gitlab.freedesktop.org/dbus/dbus/-/work_items/549
2026-05-18 17:27:27 +02:00
Philip Withnall
a93782286e Merge branch 'ebassi/xdg-projects-dir' into 'main'
Support XDG_PROJECTS_DIR

See merge request GNOME/glib!5141
2026-05-18 14:56:06 +00:00
Emmanuele Bassi
5f3b178590 Support XDG_PROJECTS_DIR
A new XDG user directory type, for non-document project files.

See: https://gitlab.freedesktop.org/xdg/xdg-user-dirs/-/work_items/3
2026-05-18 15:40:17 +01:00
Philip Withnall
b173cfca62 Merge branch 'dbus-cookie-getenv' into 'main'
gdbusauthmechanismsha1: Ignore G_DBUS_COOKIE_SHA1_KEYRING_DIR when suid

See merge request GNOME/glib!4990
2026-05-18 14:12:05 +00:00
Philip Withnall
efac370744 gdbusauthmechanismsha1: Disable auth mechanism when setuid
When running setuid, ignore this auth mechanism and hence also the
`$G_DBUS_COOKIE_SHA1_KEYRING_DIR` environment variable.

This was considered as part of #2168 but determined at the time to not
be a problem.

It’s since been reported as a vulnerability. I don’t see how it can
realistically be exploited in practice:
 - This D-Bus auth mechanism is strongly discouraged and iirc it’s only
   kept around for use on Windows
 - The setuid binary would have to be running as a D-Bus server in a
   peer-to-peer configuration, which is very rare
 - Even rarer to run it as setuid root, rather than as a system service
   via a service manager
 - And the configuration would have to force this auth mechanism to be
   used instead of any more appropriate mechanism

That said, I don’t see any reason why we _shouldn’t_ ignore this
environment variable when setuid. ¯\_(ツ)_/¯  The fallback for
`$G_DBUS_COOKIE_SHA1_KEYRING_DIR` is to build the keyring path using
`$HOME`, but that is equally as susceptible to attacker modification
when running setuid, hence we disable the whole auth mechanism.

This brings GIO inline with what libdbus does.

Spotted by cavid.
Thanks to the Sovereign Tech Resilience programme from the Sovereign
Tech Agency.

ID: #YWH-PGM9867-164
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-05-18 14:51:55 +01:00
Philip Withnall
a3326845c2 Merge branch 'markup-escape-tests' into 'main'
tests: Check that g_markup_escape_text() returns something parseable

See merge request GNOME/glib!5119
2026-05-18 13:45:21 +00:00
Philip Withnall
bc38fcb6c8 tests: Check that g_markup_escape_text() returns something parseable
Given that the whole point of `g_markup_escape_text()` is to escape
input so that it can safely be passed to the markup parser and be
treated as text, we should probably be testing that behaviour.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-05-18 14:29:59 +01:00
Philip Withnall
1a39e1baba Merge branch 'set-str-take' into 'main'
gstrfuncs: Add g_set_str_take() helper function

See merge request GNOME/glib!5118
2026-05-18 13:21:02 +00:00
Philip Withnall
98566f396d gstrfuncs: Add g_set_str_take() helper function
This is like `g_set_str()`, but it takes ownership of the new string
passed in to it, so you can conveniently pass in the return value of
`g_strdup_printf()` (etc.) without additional memory management
boilerplate.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-05-18 14:08:41 +01:00
Philip Withnall
a071d5a209 Merge branch 'wip/chergert/gtypeinstance-generic-marshaller' into 'main'
gobject/gclosure: add GTypeInstance support to generic marshaller

Closes #3954

See merge request GNOME/glib!5186
2026-05-15 16:06:34 +00:00
Christian Hergert
8610cceac8 gobject/gclosure: add GTypeInstance support to generic marshaller
This commit extends the generic marshaller to support parameter and
return types that are custom GTypeInstance. This can be useful for
situations where writing a custom marshaller is impractical or lacks the
necessary plumbing to do so, such as <closure/> in GtkExpression defined
from UI files.

Fixes: #3954
2026-05-15 16:29:51 +02:00
Philip Withnall
f1389969d8 Merge branch 'gdesktopappinfo-add-guards' into 'main'
gio/gdesktopappinfo: Add precondition assertions

See merge request GNOME/glib!5185
2026-05-15 10:45:19 +00:00
Peter Bloomfield
258dd3cf92 gio/gdesktopappinfo: Add precondition assertions 2026-05-14 19:08:46 -04:00
Philip Withnall
4fa33b09ce Merge branch 'dev-null-pollable-freebsd' into 'main'
gio/tests/pollable.c: Conditionalize on FreeBSD version in the /dev/null test case

See merge request GNOME/glib!5183
2026-05-07 14:31:59 +00:00
Gleb Popov
3983b3e22a gio/tests/pollable.c: Conditionalize on FreeBSD version in the /dev/null test case 2026-05-07 16:51:46 +03:00
Philip Withnall
34305865e6 Merge branch 'g_get_num_processors-report-performance-cores-only' into 'main'
g_get_num_processors(): on macOS, report n_pcore

See merge request GNOME/glib!5153
2026-05-06 15:04:57 +00:00
Philip Withnall
a9606213fb Merge branch 'valgrind-devenv' into 'main'
meson: Add valgrind suppression file to VALGRIND_OPTS in devenv

See merge request GNOME/glib!5180
2026-05-06 12:08:16 +00:00
Xavier Claessens
4a582ae395 meson: Add valgrind suppression file to VALGRIND_OPTS in devenv 2026-05-05 08:27:08 -04:00
Philip Withnall
0d439d3314 Merge branch 'dev-null-pollable-freebsd' into 'main'
gio/tests/pollable.c: Fix test on FreeBSD

See merge request GNOME/glib!5177
2026-05-04 13:51:27 +00:00
Gleb Popov
c18fa6e4b0 gio/tests/pollable.c: Fix test on FreeBSD 2026-05-04 13:51:27 +00:00
Philip Withnall
f56b35605d Merge branch 'gapplication-open' into 'main'
gioenums: G_APPLICATION_HANDLES_OPEN can be useful with G_APPLICATION_HANDLES_COMMAND_LINE

Closes #1853

See merge request GNOME/glib!5175
2026-05-04 12:35:26 +00:00
Guido Günther
d905f1f70b gioenums: G_APPLICATION_HANDLES_OPEN can be useful with G_APPLICATION_HANDLES_COMMAND_LINE
Update the documentation accordingly.

Closes: #1853
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2026-05-04 11:42:56 +00:00
Guido Günther
4a2c9d2f78 gioenums: Remove trailing whitespace
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2026-05-04 11:42:56 +00:00
Philip Withnall
75ee5336c7 Merge branch 'gnulib-flags-fix' into 'main'
gnulib: Fix unused flags variable warning

See merge request GNOME/glib!5176
2026-05-04 11:39:36 +00:00
Philip Withnall
cdcad0f92c gnulib: Fix unused flags variable warning
The following error has just popped up in mingw32 CI, which presumably
means the compiler has just been upgraded under our feet again:
```
../glib/gnulib/vasnprintf.c: In function '_g_gnulib_vasnprintf':
../glib/gnulib/vasnprintf.c:2429:21: error: variable 'flags' set but not used [-Werror=unused-but-set-variable=]
 2429 |                 int flags = dp->flags;
      |                     ^~~~~
cc1.exe: all warnings being treated as errors
```

This highlighted a bug in the version of gnulib we’re using, where the
`flags` variable was assigned but never used.

In lieu of updating our gnulib copylib version (which I don’t have the
energy to do right now; see #2603), copy across the fix for this issue
from upstream.

It’s upstream commit 5527d5c548702b89d217bbe58036996066a709b6.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-05-02 13:45:41 +01:00
Philip Withnall
5befbeab69 Merge branch '3931-dbus-cookie-traversal' into 'main'
gdbusauthmechanismsha1: Validate cookie context

Closes #3931

See merge request GNOME/glib!5172
2026-04-29 15:54:02 +00:00
Philip Withnall
ff97c6f5b6 tests: Add a unit test for GDBusAuthMechanismSha1 cookie context parsing
This checks for regressions in the fixes from the previous few commits.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3931
2026-04-29 16:43:00 +01:00
Philip Withnall
160ffcbbb2 Merge branch '3933-dbus-message-length-validation' into 'main'
gdbusmessage: Fix types of integer arithmetic in message length calculation

Closes #3933

See merge request GNOME/glib!5173
2026-04-29 14:21:21 +00:00
Philip Withnall
e8cfe7db69 Merge branch '3925-io-channel-overread' into 'main'
giochannel: Fix memcmp() off the end of the buffer with long terminators

Closes #3925

See merge request GNOME/glib!5170
2026-04-29 14:10:48 +00:00
Philip Withnall
d7fea6a984 Merge branch '3930-keyfile-locale-string-list-overread' into 'main'
gkeyfile: Fix a one-byte heap under-read with g_key_file_get_locale_string_list()

Closes #3930

See merge request GNOME/glib!5171
2026-04-29 13:54:21 +00:00
Philip Withnall
578a488481 gdbusmessage: Fix types of integer arithmetic in message length calculation
This fixes the addition happening with type `uint32_t`, rather than the
expected `gssize`. Because of the narrower type, this could have
resulted in integer overflow for large header lengths, bypassing the
message length check lower down in the function.

This is not exploitable in practice unless communicating peer-to-peer
with a malicious D-Bus peer, as invalid messages like this would be
filtered out by the message bus (such as `dbus-daemon`).

Rework the arithmetic to use checked arithmetic functions into a
`size_t` (largely as suggested by Simon McVittie), and add some unit
tests. Simply doing the arithmetic in the `gssize` domain would not fix
the issue on 32-bit systems.

Based on a report by Koda Reef, albeit reverse engineered as the report
did not contain a proof of concept of the vulnerability.

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

Fixes: #3933
2026-04-29 12:13:32 +01:00
Philip Withnall
3af1b31f71 Merge branch 'gnuc-flags-enum' into 'main'
docs: Add docs for G_GNUC_FLAG_ENUM

See merge request GNOME/glib!5167
2026-04-28 16:09:36 +00:00
Philip Withnall
9f557746c5 giochannel: Fix memcmp() off the end of the buffer with long terminators
If the line terminator is longer than a single byte, and the current
line extends to the end of the buffer, and the buffer (which is a
`GString`) is near a power of two in length (as that’s how `GString`s
are allocated) it’s possible for the `memcmp()` which checks the
terminator to read off the end of the string buffer.

Fix that by checking the terminator length against the last character
before calling `memcmp()`. Add a unit test.

Spotted by linhlhq as #YWH-PGM9867-199. The fix is theirs (validated by
me), and the unit test is adapted from their proof of concept.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Fixes: #3925
2026-04-28 16:45:14 +01:00
Philip Withnall
d9d2010689 gdbusauthmechanism: Expose client reject reason as a new vfunc
We can do this because `gdbusauthmechanism.h` is a private header.

Hook it up to the existing `reject_reason` code in each
`GDBusAuthMechanism` implementation, as all three implementations
currently intermingle reject reasons from the server and client code, so
there would currently be no benefit to having a separate server and
client implementation of `*_get_reject_reason()`.

This new private API will be used in a new unit test in the following
commit.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-04-28 15:51:00 +01:00
Philip Withnall
948c5984b8 gdbusauthmechanismsha1: Improve validation of cookie ID
The D-Bus specification says the cookie ID has to be non-negative, but
we weren’t checking that (or checking that it was non-empty).

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-04-28 15:49:54 +01:00