Commit Graph

27595 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
732e40dcfa gtimer: Avoid doing anything on g_usleep (0)
It's unlikely to happen, but still could be the case, so avoid do
anything.
2023-04-14 20:24:52 +02:00
Philip Withnall
7a5d4c2bb7 gfileutils: Fix potential integer overflow in g_get_current_dir()
In practice, this will never happen.

If `getcwd()` returns `ERANGE` whenever the working directory is ≥
`PATH_MAX`, though, the previous implementation of the loop would run
until `max_len == G_MAXULONG`, and would then overflow when adding `1`
to it for a nul terminator in the allocation.

Avoid that problem by always keeping `buffer_len` as a power of two, and
relying on `getcwd()` to write a nul terminator within the buffer space
it’s given. It seems to do this on all platforms we care about, because
the previous version of the code never explicitly wrote a nul terminator
anywhere.

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

Fixes: #98
2023-04-14 19:23:20 +01:00
Marco Trevisan (Treviño)
fcad56e313 meson: Add glib_valgrind_suppressions variable to glib pkg-config file
Various projects are running tests under valgrind, and they are using
the GLib suppresions to avoid false-positive results.

While this is stored in a well-known path for some years, and easy to
figure out from the GLib prefix, it's better to expose it through a
proper pkgconfig variable so that it's easy to get it from any build
system.
2023-04-14 19:20:51 +02:00
Philip Withnall
9d2f65576f Merge branch 'work-around-ucrt-spawn-env-issue' into 'main'
Work around an UCRT issue with _wspawn() functions taking an envp block

See merge request GNOME/glib!3289
2023-04-14 17:06:32 +00:00
Philip Withnall
d46405029c Merge branch 'ghash-gvariant-cheri-layout' into 'main'
Make GVariant/GHash opaque types compatible with CHERI

See merge request GNOME/glib!3146
2023-04-14 17:02:54 +00:00
Philip Withnall
da35056247 Merge branch 'registry-settings-root-key' into 'main'
gregistrysettingsbackend: Allow a different root key path

See merge request GNOME/glib!3306
2023-04-14 17:00:01 +00:00
Dario Saccavino
fee0a7679a gregistrysettingsbackend: Allow a different root key path 2023-04-14 17:00:01 +00:00
Philip Withnall
01d5b41afa Revert "gfileinfo: Temporarily downgrade missing attribute criticals to debugs"
This reverts commit 4cad66580b.

Downgrading the criticals was only temporary. Now we’ve branched for
GLib 2.78, the criticals can be reinstated early this cycle, so people
have the maximum time to fix latent bugs in their code.

Fixes: #2951
2023-04-14 17:55:37 +01:00
Philip Withnall
e86d8ccf28 Merge branch 'api-index' into 'main'
doc: Workaround missing API index

See merge request GNOME/glib!3308
2023-04-14 16:38:37 +00:00
Philip Withnall
cd118f9af0 Merge branch 'action-group-query-action' into 'main'
actiongroup: Add a compiler warning

See merge request GNOME/glib!3367
2023-04-14 16:32:54 +00:00
Luca Bacci
5d1046d3b2 Add test for UCRT issue workaround 2023-04-14 17:15:28 +01:00
Luca Bacci
911d091866 Work around an UCRT issue with _wspawn() functions taking an environment block argument
We were working around that with a call to chdir("."). Internally chdir()
sets up cmd shell-related environment variables, but only if the current
working directory belongs to a volume with a drive letter. For example,
if the current working directory is on a UNC volume like a network share,
the call to chdir() won't help.

Reference:
  https://developercommunity.visualstudio.com/t/UCRT-Crash-in-_wspawne-functions/10262748
2023-04-14 17:15:28 +01:00
Philip Withnall
353f2e4b3c Merge branch 'normalize-utf8-bounds-checking' into 'main'
g_utf8_normalize: don't read past the end of the buffer

See merge request GNOME/glib!3341
2023-04-14 16:14:54 +00:00
Xavier Claessens
8d27474631 doc: Workaround missing API index 2023-04-14 17:08:35 +01:00
Philip Withnall
8b45b81150 Merge branch 'pgorszkowski/add_signal_id_option_to_g_signal_handlers_block_matched' into 'main'
Support G_SIGNAL_MATCH_ID in g_signal_handlers_block/unblock/disconnect_matched()

Closes #2980

See merge request GNOME/glib!3376
2023-04-14 15:56:09 +00:00
Philip Withnall
f2f322005d Merge branch 'update-annotations' into 'main'
Explicitly mark size parameter as (in)

See merge request GNOME/glib!3371
2023-04-14 15:55:38 +00:00
Philip Withnall
3f390d5598 Merge branch '2307-mainloop-test-asan' into 'main'
tests: Re-enable mainloop test under AddressSanitizer

Closes #2307

See merge request GNOME/glib!3329
2023-04-14 15:55:06 +00:00
Philip Withnall
58cb296416 Merge branch 'feature/sum_apparent_size_only_for_files_and_symlinks' into 'main'
Align `G_FILE_MEASURE_APPARENT_SIZE` behaviour with `du` from GNU coreutils 9.2

Closes #2965

See merge request GNOME/glib!3358
2023-04-14 15:54:19 +00:00
Philip Withnall
11bdd6fcc4 Merge branch 'wip/jtojnar/wl-are-compiler-flags' into 'main'
build/gmodule-2.0.pc: Move compiler flags from Libs to Cflags

See merge request GNOME/glib!3356
2023-04-14 15:52:56 +00:00
Todd Carson
c82f9adb19 Test g_utf8_normalize() handling of invalid UTF-8 inputs
Add three classes of test case for which g_utf8_normalize() should
safely return NULL:
 - Strings ending with a truncated multibyte character which would
   extend past the NUL terminator
 - Strings ending with a multibyte character which extends past the
   length limit provided by the max_len argument
 - Strings containing an invalid multibyte character in any position
2023-04-14 16:52:16 +01:00
Todd Carson
7f4726d151 g_utf8_normalize: don't read past the end of the buffer
_g_utf8_normalize_wc() could read past the end of the provided buffer if
it ends with a truncated multibyte character. If max_len is -1, it can
continue reading until it encounters either a NUL or unreadable
memory. Avoid this with extra bounds checks prior to g_utf8_get_char()
to ensure that it does not read past either max_len or a NUL
terminator.
2023-04-14 16:52:10 +01:00
Philip Withnall
d5a7982eeb Merge branch 'fuzz-normalize-utf8' into 'main'
Add fuzzing harness for g_utf8_normalize()

See merge request GNOME/glib!3342
2023-04-14 15:50:48 +00:00
Todd Carson
0cfa300c00 Add fuzzing harness for g_utf8_normalize() 2023-04-14 15:50:47 +00:00
Philip Withnall
715c8064be Merge branch 'meson-system-libintl-detection' into 'main'
meson: Fix detection of a system-provided proxy-libintl

See merge request GNOME/glib!3352
2023-04-14 15:50:20 +00:00
Philip Withnall
088e2a4f5a Merge branch 'socket-nonblock' into 'main'
gsocket/inotify/gwakeup: Use SOCK_NONBLOCK and O_NONBLOCK to avoid fcntl() syscalls where possible

See merge request GNOME/glib!3347
2023-04-14 15:49:52 +00:00
Philip Withnall
17295bd0b0 Merge branch 'move-msvc-recommended-pragmas' into 'main'
meson: Move msvc_recommended_pragmas.h to a subdirectory

See merge request GNOME/glib!3340
2023-04-14 15:49:21 +00:00
Philip Withnall
1ebfe32c06 Merge branch 'gio-tool-info-strings' into 'main'
gio-tool-info: Fix a duplicate attribute name in the UI

See merge request GNOME/glib!3337
2023-04-14 15:48:43 +00:00
Philip Withnall
5611851eb9 Merge branch 'bsd-libelf-enabled' into 'main'
meson: allow -Dlibelf=enabled without pkg-config

See merge request GNOME/glib!3335
2023-04-14 15:48:20 +00:00
Philip Withnall
8a2fbe78d2 Merge branch 'post-release-version-stuff' into 'main'
build: Post-release version bump

See merge request GNOME/glib!3378
2023-04-14 15:46:08 +00:00
Philip Withnall
e993e27782 docs: Add 2.78 release series documentation pages to the build
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-14 16:09:34 +01:00
Philip Withnall
f06bc48685 build: Post-release version bump
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-14 16:09:33 +01:00
Philip Withnall
56bc6bcad2 Merge branch '1264-gdbus-double-unref' into 'main'
gdbusconnection: Fix double unref on timeout/cancel sending a message

Closes #1264

See merge request GNOME/glib!3291
2023-04-14 14:57:32 +00:00
Philip Withnall
0a84c182e2 gdbusconnection: Improve refcount handling of timeout source
The ref on the timeout source owned by `SendMessageData` was being
dropped just after attaching the source to the main context, leaving it
unowned in that struct. That meant the only ref on the source was held
by the `GMainContext` it was attached to.

This ref was dropped when returning `G_SOURCE_REMOVE` from
`send_message_with_reply_timeout_cb()`. Before that happens,
`send_message_data_deliver_error()` is called, which normally calls
`send_message_with_reply_cleanup()` and destroys the source.

However, if `send_message_data_deliver_error()` is called when the
message has already been delivered, calling
`send_message_with_reply_cleanup()` will be skipped. This leaves the
source pointer in `SendMessageData` dangling, which will cause problems
when `g_source_destroy()` is subsequently called on it.

I’m not sure if it’s possible in practice for this situation to occur,
but the code certainly does nothing to prevent it, and it’s easy enough
to avoid by keeping a strong ref on the source in `SendMessageData`.

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

Helps: #1264
2023-04-14 15:37:21 +01:00
Philip Withnall
b84ec21f9c gdbusconnection: Rearrange refcount handling of map_method_serial_to_task
It already implicitly held a strong ref on its `GTask` values, but
didn’t have a free function set so that they would be automatically
unreffed on removal from the map.

This meant that the functions handling removals from the map,
`on_worker_closed()` (via `cancel_method_on_close()`) and
`send_message_with_reply_cleanup()` had to call unref once more than
they would otherwise.

In `send_message_with_reply_cleanup()`, this behaviour depended on
whether it was called with `remove == TRUE`. If not, it was `(transfer
none)` not `(transfer full)`. This led to bugs in its callers.

For example, this led to a direct leak in `cancel_method_on_close()`, as
it needed to remove tasks from `map_method_serial_to_task`, but called
`send_message_with_reply_cleanup(remove = FALSE)` and erroneously didn’t
call unref an additional time.

Try and simplify it all by setting a `GDestroyNotify` on
`map_method_serial_to_task`’s values, and making the refcount handling
of `send_message_with_reply_cleanup()` not be conditional on its
arguments.

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

Helps: #1264
2023-04-14 15:37:21 +01:00
Philip Withnall
08a4387678 gdbusprivate: Use G_SOURCE_REMOVE in a source callback
This is equivalent to the current behaviour, but a little clearer in its
meaning.

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

Helps: #1264
2023-04-14 15:37:21 +01:00
Philip Withnall
d7c813cf5b gdbusprivate: Improve ownership docs for write_message_async()
The ownership transfers in this code are a bit complex, so adding some
extra documentation and `g_steal_pointer()` calls should hopefully help
clarify things.

This doesn’t introduce any functional changes, just code documentation.

Another drive-by improvement in the quest for #1264.

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

Helps: #1264
2023-04-14 15:37:21 +01:00
Philip Withnall
861741ef4b gdbusprivate: Ensure data->task is cleared when it returns
The existing comment in the code was correct that `data` is freed when
the task callback is called, because `data` is also pointed to by the
`user_data` for the task, and that’s freed at the end of the callback.

So the existing code was correct to take a copy of `data->task` before
calling `g_task_return_*()`.

After calling `g_task_return_*()`, the existing code unreffed the task
(which is correct), but then didn’t clear the `data->task` pointer,
leaving `data->task` dangling. That could cause a use-after-free or a
double-unref.

Avoid that risk by explicitly clearing `data->task` before calling
`g_task_return_*()`.

After some testing, it turns out this doesn’t actually fix any bugs, but
it’s still a good robustness improvement.

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

Helps: #1264
2023-04-14 15:36:32 +01:00
Przemyslaw Gorszkowski
b264585f3c gsignal: Support G_SIGNAL_MATCH_ID in g_signal_handlers_block/unblock/disconnect_matched()
Calling g_signal_handlers_block/unblock/disconnect_matched with only G_SIGNAL_MATCH_ID
do not match any handlers and return 0.

Fixes: #2980

Signed-off-by: Przemyslaw Gorszkowski <pgorszkowski@igalia.com>
2023-04-14 15:27:11 +01:00
Marco Trevisan
45300ae6ea Merge branch 'signal-handler-matching-docs' into 'main'
gsignal: Clarify documentation for GSignalMatchType matching

See merge request GNOME/glib!3377
2023-04-14 13:53:49 +00:00
Philip Withnall
2d8e38c00d gsignal: Clarify documentation for GSignalMatchType matching
The use of ‘OR’ in the existing documentation suggests that the matching
is disjunctive, but it’s actually conjunctive. Clarify that in the
documentation and add a test.

Spotted while reviewing
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3376.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-14 13:55:20 +01:00
Emmanuele Bassi
2f828ef2d4 Merge branch '95-markup-docs' into 'main'
docs: Add simple GMarkup parser example

Closes #95

See merge request GNOME/glib!3364
2023-04-13 21:37:41 +00:00
Emmanuele Bassi
b94d0c2168 Merge branch '799-app-info-monitor-docs' into 'main'
gappinfo: Clarify one-shot behaviour of GAppInfoMonitor::changed in docs

Closes #799

See merge request GNOME/glib!3346
2023-04-13 21:37:36 +00:00
Emmanuele Bassi
2af45f9c20 Merge branch 'libicu-tests' into 'main'
unicode: add tests for g_utf8_normalize() and empty strings

See merge request GNOME/glib!3326
2023-04-13 21:35:51 +00:00
Emmanuele Bassi
18ae2a3d4e Merge branch '322-proxy-subclass-example' into 'main'
tests: Finish update of gdbus-example-proxy-subclass to new GDBus API

Closes #322

See merge request GNOME/glib!3332
2023-04-13 21:35:13 +00:00
Emmanuele Bassi
2972cb61f5 Merge branch 'update-unicode-normalisation-tests' into 'main'
tests: Update Unicode normalisation tests from Unicode 15

See merge request GNOME/glib!3351
2023-04-13 21:33:23 +00:00
Emmanuele Bassi
28209912ef Merge branch '2969-date-time-format-docs' into 'main'
gdatetime: Improve Markdown formatting of g_date_time_format() docs

Closes #2969

See merge request GNOME/glib!3362
2023-04-13 21:32:57 +00:00
Philip Withnall
9e83c0e37e Merge branch 'docs-2963' into 'main'
README.win32.md: Update info for G_PLATFORM_WIN32

Closes #2963

See merge request GNOME/glib!3363
2023-04-13 15:27:49 +00:00
Emmanuele Bassi
ee119b4f02 Merge branch '252-classed-docs' into 'main'
gtype: Improve documentation for G_TYPE_IS_CLASSED and interfaces

Closes #252

See merge request GNOME/glib!3374
2023-04-13 14:52:47 +00:00
Philip Withnall
d1eb9c840c tests: Add type flag tests for interfaces
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #252
2023-04-13 15:39:37 +01:00
Philip Withnall
783f1b8640 gtype: Improve documentation for G_TYPE_IS_CLASSED and interfaces
The documentation previously implicitly said in a few places that
interfaces are classed, but reading through the implementation of
`GType`, I don’t think they are. If they were, the registration of the
fundamental `G_TYPE_INTERFACE` in `gobject_init()` would specify
`G_TYPE_FLAG_CLASSED`. It only specifies `G_TYPE_FLAG_DERIVABLE`.

I think this makes sense, because you can’t subclass an interface.
Subclassing is a key property of being classed.

Tweak the `GType` tutorial to remove that implicit statement, and expand
the documentation for `G_TYPE_IS_CLASSED`.

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

Fixes: #252
2023-04-13 15:37:00 +01:00