30790 Commits

Author SHA1 Message Date
Philip Withnall
4fc67fd461
2.82.5
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2.82.5
2025-02-20 13:08:16 +00:00
Philip Withnall
c9b03bdb7c Merge branch 'backport-4498-datetime-overflow-glib-2-82' into 'glib-2-82'
Backport !4498 “gdatetime: Fix integer overflow when parsing very long ISO8601 inputs” to glib-2-82

See merge request GNOME/glib!4499
2025-02-18 19:52:55 +00:00
Philip Withnall
7f6d81130e
tests: Add some missing GDateTime ISO8601 parsing tests
This improves test coverage, adding coverage for some lines which I
spotted were not covered while testing the preceding commits.

It doesn’t directly test the preceding commits, though.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-18 19:30:49 +00:00
Philip Withnall
4c56ff8034
gdatetime: Factor out an undersized variable
For long input strings, it would have been possible for `i` to overflow.
Avoid that problem by using the `tz_length` instead, so that we count up
rather than down.

This commit introduces no functional changes (outside of changing
undefined behaviour), and can be verified using the identity
`i === length - tz_length`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-18 19:30:43 +00:00
Philip Withnall
804a395772
gdatetime: Factor out some string pointer arithmetic
Makes the following code a little clearer, but doesn’t introduce any
functional changes.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-18 19:30:36 +00:00
Philip Withnall
5e8a3c19fc
gdatetime: Track timezone length as an unsigned size_t
It’s guaranteed to be in (0, length] by the calculations above.

This avoids the possibility of integer overflow through `gssize` not
being as big as `size_t`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-18 19:30:30 +00:00
Philip Withnall
495c85278f
gdatetime: Fix potential integer overflow in timezone offset handling
This one is much harder to trigger than the one in the previous commit,
but mixing `gssize` and `gsize` always runs the risk of the former
overflowing for very (very very) long input strings.

Avoid that possibility by not using the sign of the `tz_offset` to
indicate its validity, and instead using the return value of the
function.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-18 19:30:23 +00:00
Philip Withnall
fe6af80931
gdatetime: Fix integer overflow when parsing very long ISO8601 inputs
This will only happen with invalid (or maliciously invalid) potential
ISO8601 strings, but `g_date_time_new_from_iso8601()` needs to be robust
against that.

Prevent `length` overflowing by correctly defining it as a `size_t`.
Similarly for `date_length`, but additionally track its validity in a
boolean rather than as its sign.

Spotted by chamalsl as #YWH-PGM9867-43.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-18 19:30:16 +00:00
Michael Catanzaro
e57e10f0f2 Merge branch 'backport-4442-meson-subproject-test-setups-glib-2-82' into 'glib-2-82'
Backport !4442 “Don't mark test setups as default in subprojects” to glib-2-82

See merge request GNOME/glib!4482
2025-02-11 10:33:02 +00:00
Matthias Clasen
38994d43ea Don't mark test setups as default in subprojects
This is problematic since meson is defective when it comes to
default test setups. It only allows a single such across all
(sub)projects.

See https://github.com/mesonbuild/meson/issues/12700
2025-02-10 16:28:55 +00:00
Emmanuele Bassi
212991ea4f Merge branch 'wip/pwithnall/backport-4462-macos-appinfo-crash-glib-2-82' into 'glib-2-82'
Backport !4462 “gosxappinfo: Correctly launch list of files” to glib-2-82

See merge request GNOME/glib!4463
2025-01-31 13:44:17 +00:00
Andre Miranda
e05c492bd9 gosxappinfo: Fix leak
Slightly reworked by Philip Withnall (any mistakes his).
2025-01-28 12:04:29 +00:00
Andre Miranda
2c55c9584a gosxappinfo: Correctly launch list of files
Fixes #3587
2025-01-24 13:16:26 +00:00
Philip Withnall
ca20e4ac71
2.82.4
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2.82.4
2024-12-11 22:21:22 +00:00
Emmanuele Bassi
899caabcda Merge branch 'wip/pwithnall/release-infra-glib-2-82' into 'glib-2-82'
Backport !4432 and !4433 “ci: Add release component to automate tarball publishing” to glib-2-82

See merge request GNOME/glib!4434
2024-12-11 18:34:52 +00:00
Philip Withnall
49a1b51141
ci: Fix output paths for docs tarballs in dist-job
Otherwise they’re not picked up as artifacts, and hence are basically
lost.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-11 17:50:21 +00:00
Philip Withnall
72fe3b5970
ci: Run dist-job on a schedule as well as on tags
This will allow us to test that it actually still works, which is
important for being able to make releases, because once we push a tag,
there’s no going back. The release can’t happen if `dist-job` then fails
on that tag.

Sigh.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-11 17:50:14 +00:00
Philip Withnall
1c318263d4
ci: Clear dependencies for dist-job
Otherwise it never executes, because it’s waiting patiently for zero
dependencies to complete. 🤦

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-11 17:50:07 +00:00
Philip Withnall
f2488ef526
ci: Enable -Dintrospection for dist builds
This means that the documentation can actually be generated, which was
broken before. Building the documentation requires `enable_gir`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-11 17:50:01 +00:00
Philip Withnall
53c197bd61
ci: Slightly improve quoting of variables
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-11 17:41:47 +00:00
Jordan Petridis
89b79e3af7
ci: Add release component to automate tarball publishing
Publishing the dist tarball to download.gnome.org is now automated.

See [1]

[1] https://gitlab.gnome.org/Teams/Websites/handbook.gnome.org/-/merge_requests/83/
2024-12-11 17:41:41 +00:00
Philip Withnall
d02c95c91a Merge branch 'backport-4427-revert-dbus-method-invocation-refcounting-glib-2-82' into 'glib-2-82'
Backport !4427 “Revert "gdbus: Fix leak of method invocation when registering an object with closures"” to glib-2-82

See merge request GNOME/glib!4430
2024-12-11 13:23:57 +00:00
Philip Withnall
557d2e498d
gdbusconnection: Document existing refcount semantics of closures
As per the previous few commits, explicitly document the established
reference counting semantics of the method call closure for
`g_dbus_connection_register_object_with_closures()`.

This isn’t ideal, but
`g_dbus_connection_register_object_with_closures()` has had these
semantics for 10 years now, and it’s a bit late to change them to
something neater.

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

Helps: #3559
2024-12-11 12:47:23 +00:00
Philip Withnall
1b66bf4122
gdbusconnection: Add a comment explaining why an invocation is ‘leaked’
It’s not leaked, it’s transferred forwards to the eventual
`g_dbus_method_invocation_return_*()` call.

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

Helps: #3559
2024-12-11 12:47:16 +00:00
Philip Withnall
60e9deb2b0
Revert "gdbus: Fix leak of method invocation when registering an object with closures"
This reverts commit 092fedd5f085a2f1966b5c34befe8b603c1a0f07.

This was not the right change to make, and I shouldn’t have accepted the
MR. The situation is laid out in this comment:
https://gitlab.gnome.org/GNOME/glib/-/issues/2600#note_1385050

tl;dr: The reference on the `GDBusMethodInvocation` which is transferred
in to the `GDBusInterfaceMethodCallFunc` is balanced by a reference
transferred to `g_dbus_method_invocation_return_*()`. This is how the
refcounting has always worked for these functions, and even if we’d
probably arrange things differently if the code was written now, we
can’t change those semantics without breaking API.

In particular, bindings have various bits of custom code to account for
these reference tranfers (since they can’t be represented using
gobject-introspection annotations), so changing the semantics will break
bindings.

Fixes: #3559
2024-12-11 12:47:10 +00:00
Philip Withnall
4159df97f5
2.82.3
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2.82.3
2024-12-09 14:39:08 +00:00
Philip Withnall
8ef46818e3 Merge branch 'backport-4415-dbus-leak-glib-2-82' into 'glib-2-82'
Backport !4415 “gdbus: Fix leak of method invocation when registering an object with closures” to glib-2-82

See merge request GNOME/glib!4417
2024-12-03 20:14:15 +00:00
Philip Withnall
8f7619e140 Merge branch 'backport-4415-dbus-leak-glib-2-82' into 'glib-2-82'
Backport !4415 “gdbus: Fix leak of method invocation when registering an object with closures” to glib-2-82

See merge request GNOME/glib!4417
2024-12-03 20:12:23 +00:00
Sebastian Dröge
77b50ce7d2 gdbus: Fix leak of method invocation when registering an object with closures
The invocation passed in is owned by the callback.
2024-12-02 18:39:00 +00:00
Emmanuele Bassi
339e06125e Merge branch 'backport-4398-refstring-disable-assert-fix-glib-2-82' into 'glib-2-82'
Backport !4398 “grefstring: Mark a variable as potentially unused” to glib-2-82

See merge request GNOME/glib!4400
2024-11-26 23:45:02 +00:00
Philip Withnall
f996d026af
grefstring: Mark a variable as potentially unused
It is unused when compiling with `G_DISABLE_ASSERT`. That’s fine, but we
definitely want the `g_hash_table_remove()` call to still be made.

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

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-11-14 12:55:20 +00:00
Philip Withnall
398bdd16dc Merge branch 'backport-4395-appmonitor-test-build-fix-glib-2-82' into 'glib-2-82'
Backport !4395 “appmonitor: Fix warning building test” to glib-2-82

See merge request GNOME/glib!4397
2024-11-13 14:39:10 +00:00
Bastien Nocera
f5c00f1656 appmonitor: Fix warning building test
gio/tests/appmonitor.c: In function ‘timeout_cb’:
gio/tests/appmonitor.c:95:14: warning: null pointer dereference [-Wnull-dereference]
   95 |   *timed_out = TRUE;
2024-11-13 13:45:26 +00:00
Emmanuele Bassi
3e74b0a3ea Merge branch 'backport-4232-refstring-race-glib-2-82' into 'glib-2-82'
Backport !4232 “refstring: Fix race between releasing and re-acquiring an interned GRefString” to glib-2-82

See merge request GNOME/glib!4388
2024-11-08 13:02:48 +00:00
Sebastian Dröge
79bfee1371
refstring: Fix race between releasing and re-acquiring an interned GRefString
There is a race between releasing and re-acquiring an interned
GRefString if this happens on two threads at the same time. This can
result in already freed memory to be returned from
g_ref_string_new_intern().

| Thread 1                       | Thread 2                      |
| ------------------------------ | ----------------------------- |
| g_ref_string_release()         | g_ref_string_new_intern()     |
| g_atomic_rc_box_release_full() | g_mutex_lock()                |
|                                | g_hash_table_lookup()         |
| remove_if_interned()           | g_ref_string_acquire()        |
| g_mutex_lock()                 | g_mutex_unlock()              |
| g_hash_table_remove()          |                               |
| g_mutex_unlock()               |                               |
| g_free()                       |                               |
|                                | return res; // this is freed  |

This use-after-free usually also gives a critical warning because
g_atomic_ref_count_inc() checks for the refcount having been 0
before incrementing.

It is not possible to safely implement weak references via garcbox.

To avoid this race do not implement weak references via garcbox but
instead implement the allocation of the string manually with a manually
managed reference count. This allows to safely resurrect the interned
string if the above race happens, and also avoids other races.

As a side-effect this also

  * reduces the allocation size in addition to the actual string length
    from 32 bytes to 16 bytes on 64 bit platforms and keeps it at 16 bytes
    on 32 bit platforms,

  * doesn't lock a mutex when freeing non-interned GRefStrings.

Cherry-pick to `glib-2-82`: Drop changes to `g_ref_string_equal()`,
which doesn’t exist on this branch.
2024-11-08 12:36:50 +00:00
Sebastian Dröge
546b15312f arcbox: Document that implementing weak references via the clear_func is not safe 2024-11-08 12:35:09 +00:00
Michael Catanzaro
de7779fbd3 Merge branch 'backport-4373-macos-ico-fix-glib-2-82' into 'glib-2-82'
Backport !4373 “macos: Remove extraous space from type identifier” to glib-2-82

See merge request GNOME/glib!4381
2024-11-04 17:58:10 +00:00
Arjan Molenaar
828ca6978a macos: Remove extraous space from type identifier 2024-11-04 17:06:31 +00:00
Michael Catanzaro
0fb140c035 Merge branch 'backport-4378-gio-tool-leaks-glib-2-82' into 'glib-2-82'
Backport !4378 “gio: Fix GFileEnumerator leaks in gio tools” to glib-2-82

See merge request GNOME/glib!4380
2024-11-04 16:09:17 +00:00
correctmost
2dd1395e05 gio: Fix GFileEnumerator leaks in gio tools 2024-11-04 15:41:56 +00:00
Michael Catanzaro
d23ca8c7db Merge branch 'backport-4350-glib-domain-fix-glib-2-82' into 'glib-2-82'
Backport !4350 “glib: Don't require GLIB_DOMAIN to be a NUL-terminated string” to glib-2-82

See merge request GNOME/glib!4370
2024-10-25 02:20:38 +00:00
Sebastian Dröge
ea790e0504 glib: Add test for handling of non-NUL terminated strings in default log handler 2024-10-24 21:43:45 +01:00
Sebastian Dröge
44fb7c5b54 glib: Make sure GLIB_OLD_LOG_API is a NUL-terminated string
Every usage in GLib ensures this but theoretically external code might
pass something else. As this is only meant to be used internally from
GLib, don't support the other case but at least avoid potential out of
bound reads.
2024-10-24 21:43:45 +01:00
Sebastian Dröge
5bc28aff95 glib: Don't require GLIB_DOMAIN to be a NUL-terminated string
The length might be passed explicitly in the field instead, and the
string might not have a NUL-terminator as happens for example when
passed from the Rust bindings.

This might lead to out of bounds reads.

Thanks to Sebastian Wiesner for noticing this.
2024-10-24 21:43:45 +01:00
Simon McVittie
7e4fcb4fa8 Merge branch 'backport-4356-tzdata-glib-2-82' into 'glib-2-82'
Backport !4356 “gdatetime test: Do not assume PST8PDT was always exactly -8/-7” to glib-2-82

See merge request GNOME/glib!4357
2024-10-18 11:53:31 +00:00
Simon McVittie
0b12ce089e gdatetime test: Fall back if legacy System V PST8PDT is not available
On recent versions of Debian, PST8PDT is part of the tzdata-legacy
package, which is not always installed and might disappear in future.
Successfully tested with and without tzdata-legacy on Debian unstable.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-18 12:09:32 +01:00
Simon McVittie
44287620ba gdatetime test: Try to make PST8PDT test more obviously correct
Instead of using timestamp 0 as a magic number (in this case interpreted
as 1970-01-01T00:00:00-08:00), calculate a timestamp from a recent
year/month/day in winter, in this case 2024-01-01T00:00:00-08:00.

Similarly, instead of using a timestamp 15 million seconds later
(1970-06-23T15:40:00-07:00), calculate a timestamp from a recent
year/month/day in summer, in this case 2024-07-01T00:00:00-07:00.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-18 12:09:32 +01:00
Rebecca N. Palmer
57fa3b16a7 gdatetime test: Do not assume PST8PDT was always exactly -8/-7
In newer tzdata, it is an alias for America/Los_Angeles, which has a
slightly different meaning: DST did not exist there before 1883. As a
result, we can no longer hard-code the knowledge that interval 0 is
standard time and interval 1 is summer time, and instead we need to look
up the correct intervals from known timestamps.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3502
Bug-Debian: https://bugs.debian.org/1084190
[smcv: expand commit message, fix whitespace]
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-18 12:09:31 +01:00
Philip Withnall
45b469ea32
2.82.2
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2.82.2
2024-10-17 12:08:41 +01:00
Michael Catanzaro
e1f33e5559 Merge branch 'backport-4348-data-input-stream-read-line-utf8-fix-glib-2-82' into 'glib-2-82'
Backport !4348 “gdatainputstream: Fix length return value on UTF-8 validation failure“ to glib-2-82

See merge request GNOME/glib!4349
2024-10-12 18:34:44 +00:00