Commit Graph

7674 Commits

Author SHA1 Message Date
Loic Le Page
7178e10cd5 Fix redefinition of local variable in gio/tests/testfilemonitor.c 2022-04-01 15:10:50 +02:00
Loic Le Page
c324ce5c2a Fix redefinition of local variable in gio/gactiongroupexporter.c 2022-04-01 15:10:50 +02:00
Loic Le Page
3214a0f333 Fix redefinition of local variable in gio/gapplicationimpl-dbus.c 2022-04-01 15:10:50 +02:00
Loic Le Page
0c1619227c Fix redefinition of local variable in gio/gdbus-tool.c 2022-04-01 15:10:50 +02:00
Loic Le Page
4bcb7bc631 Fix redefinition of local variable in gio/gdbusauth.c 2022-04-01 15:10:50 +02:00
Loic Le Page
eb157bfa1b Fix redefinition of local variable in gio/gdbusauthmechanismsha1.c 2022-04-01 15:10:41 +02:00
Loic Le Page
bf68e8606b Fix non-initialized variable and remove obsolete usage of inet_addr in gio/gsocket.c 2022-04-01 00:18:40 +01:00
Loic Le Page
7bde242707 Fix redefinition of local variable in gio/gsocks5proxy.c 2022-04-01 00:18:40 +01:00
Loic Le Page
bd5d867320 Fix global variable name hidden by local variables in gio/gthreadedresolver.c 2022-04-01 00:18:40 +01:00
Loic Le Page
49d0c5a90b Fix redefinition of local variable in gio/gtlscertificate.c 2022-04-01 00:18:40 +01:00
Loic Le Page
84dabcf274 Fix global and local variables hidden by local variables and non-initialized variables in gio/gwin32appinfo.c 2022-04-01 00:18:40 +01:00
Loic Le Page
155657de3e Fix redefinition of local variable in gio/gwin32file-sync-stream.c 2022-04-01 00:18:40 +01:00
Philip Withnall
f8302d29f1 Merge branch 'wip/smcv/simplify-openpty-linking' into 'main'
tests: Call openpty (if available) without using dlsym

See merge request GNOME/glib!2562
2022-03-31 15:09:46 +00:00
Loic Le Page
6888f9e17e Fix too small array definition in gio/gdummyfile.c (no room for the '\0') 2022-03-31 13:10:26 +01:00
Loic Le Page
5ec3a425d2 Fix non-initialized variable in gio/gfile.c 2022-03-31 13:10:25 +01:00
Loic Le Page
397ccd833b Fix global variable name hidden by local variables in gio/gfileinfo.c 2022-03-31 13:10:25 +01:00
Loic Le Page
cbdddf82c0 Fix global variable name hidden by local variables in gio/gio-tool-info.c 2022-03-31 13:10:25 +01:00
Loic Le Page
72cc5b3910 Fix global variable name hidden by local variables in gio/gio-tool-list.c 2022-03-31 13:10:25 +01:00
Loic Le Page
71de9553ca Fix global variable name hidden by local variables in gio/gio-tool-mount.c 2022-03-31 13:10:25 +01:00
Loic Le Page
c0dabdd8df Fix global variable name hidden by local variables in gio/gio-tool-save.c 2022-03-31 13:10:25 +01:00
Loic Le Page
781231d556 Fix global variable name hidden by local variables in gio/gio-tool-trash.c 2022-03-31 13:10:25 +01:00
Loic Le Page
a30ae2497d Fix redefinition of local variable in gio/giomodule.c 2022-03-31 13:10:25 +01:00
Loic Le Page
94264e6190 Fix redefinition of local variable in gio/giowin32-private.c 2022-03-31 13:10:25 +01:00
Sebastian Dröge
1fc402b33b Merge branch '2614-bye-bye-gamin' into 'main'
gio: Remove fam file monitor support

Closes #2614

See merge request GNOME/glib!2570
2022-03-23 16:45:04 +00:00
Philip Withnall
6aa210e6af gio: Remove fam file monitor support
libgamin was last released in 2007 and is dead
[upstream](https://gitlab.gnome.org/Archive/gamin). Distributions may
still ship it (although Fedora no longer does), but we want people to
use inotify on Linux since it’s actively supported.

BSDs use kqueue. Windows uses win32filemonitor.

FAM might still be used on some commercial Unix distributions, but there
are no contributors from those distributions, and certainly no CI for
them to prevent regressions.

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

Fixes: #2614
2022-03-23 15:41:54 +00:00
Philip Withnall
2759dd71be gio: Remove remaining references to fen file monitor
It used to exist on Solaris, but GLib’s support for it was mostly
removed in 2015 in commit 21ab660cf8.

Remove the final few references.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-23 15:40:41 +00:00
Marc-André Lureau
517bd62840 gio/win32: TIME_CREATED_USEC is u32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-23 19:34:32 +04:00
Philip Withnall
f9ef3bec68 gthreadedresolver: Only declare private test APIs on Unix
They’re only defined on Unix anyway. `GThreadedResolver` has an entirely
different code path for handling DNS replies on Windows.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:41:08 +00:00
Philip Withnall
e8e8aebcbe resolver: Add SRV support to manual resolver test
This allows for tests like:
```
resolver -t SRV _http._tcp.mxtoolbox.com
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Philip Withnall
33204fe127 tests: Add tests for parsing specific DNS record types
Success and failure tests. This massively increases test coverage for
parsing DNS records, although it doesn’t get it to 100%.

It should now be useful enough to do more fuzzing on, without
immediately getting trivial failures from the fuzzer.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Philip Withnall
0d42af06e0 gthreadedresolver: Treat query and answer counts as unsigned
They can’t be negative.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Philip Withnall
08dee06b59 gthreadedresolver: Limit length of each record to its stated rdlength
Rather than limiting them to the full length of the answer, which may
include subsequent records.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Philip Withnall
023fab80f9 gthreadedresolver: Add error checking to all record parsing
This should catch all kinds of invalid records, and correctly report
them as errors.

Heavily based on work by Patrick Griffis in !2134.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Philip Withnall
81193c5aac gthreadedresolver: Don’t warn on unrecognised record types
Otherwise the code isn’t forwards-compatible, and may be DOSed by
servers returning unknown records, if `G_DEBUG=fatal-warnings` is
enabled for some reason.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Philip Withnall
51f70fe62e tests: Add tests for invalid DNS response header parsing
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Philip Withnall
2a7b4db243 gthreadedresolver: Expose g_resolver_record_type_to_rrtype()
So that it can be used in the tests.

It’s not part of the public, documented, supported API.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Philip Withnall
8b73d7bbf9 gthreadedresolver: Handle error returns from dn_expand() in headers
It is possible for `dn_expand()` to fail; if so, it’ll return `-1`,
which will mess up subsequent parsing.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Philip Withnall
263ca69da8 gthreadedresolver: Check header length when parsing response
Otherwise we could read off the end of an invalid response.

oss-fuzz#42538
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-22 12:40:12 +00:00
Patrick Griffis
5cdacced3f tests: Add basic test framework for GResolver DNS parsing
Split out from https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2134
by Philip Withnall so it can be used in advance of HTTPS DNS record
support landing.

Reworked to no longer use test fixtures, as it’s simple enough to build
the response header in each test.

The tests are built on Unix only, as they test the parsing code in
`g_resolver_records_from_res_query()`, which is Unix-specific. The
Windows DNS APIs provide much more structured results which don’t need
parsing.
2022-03-22 12:40:12 +00:00
Philip Withnall
2e940e125f Merge branch 'w32-skips' into 'main'
Various win32 tests skip & fixes

See merge request GNOME/glib!2540
2022-03-21 12:19:24 +00:00
Simon McVittie
1726e150f4 tests: Call openpty (if available) without using dlsym
The SONAME of libutil varies between architectures, so the logic to find
the SONAME of libutil was only correct for native builds (Linux on
Linux), not for cross-builds. The regular expression was also not
sufficiently broad to match the SONAME used on the alpha architecture,
which is apparently libutil.so.1.1.

Instead of screen-scraping the output of ldconfig and using that to
dlopen the library that contains openpty, it seems more reliable to
emit a link-time reference to openpty and let the linker do its job.
It's also less code.

Bug-Debian: https://bugs.debian.org/1007946
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-03-19 14:10:51 +00:00
Philip Withnall
c53129911c Merge branch 'power-profile-monitor-docs' into 'main'
gpowerprofilemonitor: Tweak wording of documentation to make more sense

See merge request GNOME/glib!2534
2022-03-18 11:34:47 +00:00
Sebastian Dröge
73f918b376 Merge branch 'gdbus-method-invocation-leak' into 'main'
gdbusmethodinvocation: Fix a leak on an early return path

See merge request GNOME/glib!2557
2022-03-18 09:25:28 +00:00
Marc-André Lureau
e38e92e37b gio/tests/codegen: skip tests that require /dev/stdout on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:20:14 +04:00
Marc-André Lureau
b3d6946c27 tests/socket: skip a test if AF_UNIX is not supported on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:16:38 +04:00
Marc-André Lureau
e014b9272a gio/tests: skip filemonitor tests on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:16:38 +04:00
Marc-André Lureau
cfc47558fc tests: enable defaultvalue and debugcontroller on win32
The test still requires dbus-daemon.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:16:38 +04:00
Marc-André Lureau
e9d9edde82 tests: skip appmonitor test on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-18 00:16:14 +04:00
Philip Withnall
a7750cd020 tests: Add unit tests for GDBusMethodInvocation
These should cover everything to do with returning a value or error from
a `GDBusMethodInvocation` object.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-17 19:17:41 +00:00
Philip Withnall
7143457076 gdbusmethodinvocation: Drop redundant quote from warning message
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-17 19:05:56 +00:00
Philip Withnall
76f5460107 gdbusmethodinvocation: Fix dead code for type checking GetAll
`property_info` is only ever set for `Get` and `Set` calls, not for
`GetAll`, as it only represents a single property. So this code was
never reachable.

Move it out so that it is reachable.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-17 19:05:56 +00:00
Philip Withnall
a3b8846e54 gdbusmethodinvocation: Fix a leak on an early return path
When doing an early return from `g_dbus_method_invocation_return_*()`
due to passing in the wrong type (or no return value when one was
expected), the parameters were not correctly sunk and were leaked.

Fix that. A unit test will be added in a following commit.

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

Coverity CID: #1474536
2022-03-17 19:04:42 +00:00
Philip Withnall
4ef27174af tests: Use g_strv_contains() rather than a home-grown version
The public `g_strv_contains()` API didn’t exist at the time this code
was originally written. Now, happily, it does.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-17 16:28:41 +00:00
Philip Withnall
e4d77f7e89 gdbusconnection: Use g_strv_contains() rather than a home-grown version
The public `g_strv_contains()` API didn’t exist at the time this code
was originally written. Now, happily, it does.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-17 16:24:08 +00:00
Philip Withnall
9b77b75f2d Merge branch 'w32-contenttype' into 'main'
Various contenttype-related test fixes on win32

See merge request GNOME/glib!2499
2022-03-17 15:14:14 +00:00
Philip Withnall
96279325b7 Merge branch 'cleanup-warnings-split-6' into 'main'
Cleanup warnings split 6

See merge request GNOME/glib!2495
2022-03-17 15:13:14 +00:00
Philip Withnall
1756dde873 Merge branch '2312-codegen-test-leak-fix' into 'main'
tests: Fix a leak in gdbus-test-codegen test

Closes #2312

See merge request GNOME/glib!2546
2022-03-17 15:12:08 +00:00
Michael Catanzaro
69a1867d51 gtlsconnection: fix typo in docs
Grrr, copy/paste error detected.
2022-03-16 10:38:34 +00:00
Philip Withnall
96caca2b7a tests: Explicitly close stream in converter-stream
When the test has finished writing all the expanded content into the
socket, explicitly close the output stream, which should make the input
stream readable and non-blocking.

The code intended to do this before, but only as a side-effect of
dropping its last reference to `right`. If another reference was being
held to `right` somewhere else, it wouldn’t end up being closed, which
would lead to failures like
https://gitlab.gnome.org/GNOME/glib/-/jobs/1890000:
```
(/var/tmp/gitlab_runner/builds/Ff4WDDRj/0/GNOME/glib/_build/gio/tests/converter-stream:56570): GLib-GIO-DEBUG: 12:56:23.280: GSocketClient: Connection successful!
Bail out! GLib-GIO:ERROR:../gio/tests/converter-stream.c:1042:test_converter_pollable: assertion failed (error == NULL): Resource temporarily unavailable (g-io-error-quark, 27)
stderr:
```

This is a bit of a guess (I’m not sure it’ll fix the intermittent test
error, as I haven’t been able to reproduce that locally), but it’s worth
a try.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-14 17:59:37 +00:00
Philip Withnall
8cff531520 tests: Isolate directory access for gdbus-connection-flush test
When multiple tests were run in parallel, this would race on its access
to `~/.dbus-keyrings` to authenticate with the D-Bus server, since the
keyring directory was not appropriately sandboxed to the unit test.

Use `G_TEST_OPTION_ISOLATE_DIRS` to automatically isolate each unit
test’s directory usage.

This should hopefully fix the failure seen in
https://gitlab.gnome.org/GNOME/glib/-/jobs/1849524, where the following
was in the log for a test executed in parallel:
```
GDBus-DBUS_COOKIE_SHA1: Deleted stale lock file '/home/user/.dbus-keyrings/org_gtk_gdbus_general.lock'
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 00:03:05 +00:00
Philip Withnall
a3c768732d tests: Isolate directory access for gdbus-non-socket test
When multiple tests were run in parallel, this would race on its access
to `~/.dbus-keyrings` to authenticate with the D-Bus server, since the
keyring directory was not appropriately sandboxed to the unit test.

Use `G_TEST_OPTION_ISOLATE_DIRS` to automatically isolate each unit
test’s directory usage.

This should hopefully fix the failure seen in
https://gitlab.gnome.org/pwithnall/glib/-/jobs/1879558.
```
228/266 glib:gio / gdbus-non-socket             FAIL     8.64 s (killed by signal 6 SIGABRT)
…
--- stderr ---
GDBus-DBUS_COOKIE_SHA1: Deleted stale lock file '/home/user/.dbus-keyrings/org_gtk_gdbus_general.lock'
**
GLib-GIO:ERROR:../gio/tests/gdbus-non-socket.c:253:test_non_socket: assertion failed (error == NULL): Exhausted all available authentication mechanisms (tried: EXTERNAL, DBUS_COOKIE_SHA1) (available: EXTERNAL, DBUS_COOKIE_SHA1) (g-io-error-quark, 0)
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-11 23:56:18 +00:00
Philip Withnall
404d5d40e0 tests: Ensure timeout source is removed in gdbus-auth test
If the whole set of tests takes more than 5 seconds, the failure timeout
from the first test could still trigger, causing an incorrect failure.

Ensure the timeout is removed at the end of each test.i

This will hopefully fix the CI failure seen here:
https://gitlab.gnome.org/pwithnall/glib/-/jobs/1879558.
```
204/266 glib:gio / gdbus-auth                   FAIL     9.21 s (killed by signal 5 SIGTRAP)
…
ok 1 /gdbus/auth/client/EXTERNAL
Bail out! GLib-GIO-FATAL-ERROR: Timeout waiting for client
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-11 23:47:22 +00:00
Loic Le Page
7a50259345 Fix redefinition of local variable in gio/glib-compile-schemas.c 2022-03-09 17:19:02 +01:00
Loic Le Page
9380a8cdb0 Fix redefinition of local variable in gio/glocalfilemonitor.c 2022-03-09 17:19:02 +01:00
Loic Le Page
d0dfc76554 Fix redefinition of local variable and non-initialized variable in gio/glocalfileoutputstream.c 2022-03-09 17:18:03 +01:00
Philip Withnall
bed82b807f tests: Re-enable address sanitizer for gdbus-test-codegen
Now that the leaks are fixed, this test can be run under the sanitizer
again.

This is a partial revert of commit
f378352051.

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

Helps: #2312
2022-03-09 14:21:22 +00:00
Philip Withnall
9499aeb8bf tests: Wait for signal unsubscriptions in gdbus-test-codegen
When destroying `GDBusProxy`s in a custom `GMainContext`, the context
must be iterated enough after finalisation of the proxies that any
pending D-Bus traffic, and the signal subscription data, can be freed.

See the documentation for `g_dbus_connection_signal_unsubscribe()`.

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

Fixes: #2312
2022-03-09 14:21:20 +00:00
Marc-André Lureau
b0c53559c0 tests: skip check anything is octet-stream
Like on Mac, the contenttype database can't say that much yet.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
7fa4999457 tests: skip test_tree on win32
Currently it simply crashes, because types == NULL.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
5f1bae1594 gio/tests: fix test_icon on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
452d64a03b tests: use Windows mime type for executable
According to https://stackoverflow.com/a/43916291/1277510

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
b60b0ec72d gio: relax g_content_type_is_a on win32
This is quite gross, but it looks like the whole content-type code on
Windows is similar. Pass test_subtype.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
ab0c00bd7e gio/tests: fix various content type guesses on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
529e091bb5 gio/tests: fix content type guess for directory on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
9d852bc6f3 gio: implement simple directory type detection
Use a logic similar to what is done for Unix, based on trailing path
separator.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:30 +04:00
Marc-André Lureau
b3379557af gio: return '*' content type on win32 from unknown mime
This fixes test_unknown.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-09 11:41:20 +04:00
Philip Withnall
0239ae7122 tests: Fix a leak in gdbus-test-codegen test
The `ay` property has type `string` (see the generated code) since it’s
not been annotated to force accepting a `GVariant`.

This means the GObject property machinery expects a string, and calls
`g_strdup()` on the passed-in pointer, rather than sinking the
`GVariant`.

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

Helps: #2312
2022-03-08 20:08:43 +00:00
Emmanuele Bassi
618d6873fd Merge branch 'wip/pwithnall/ci-fixes' into 'main'
Various unit test fixes

See merge request GNOME/glib!2538
2022-03-07 09:24:10 +00:00
Philip Withnall
4d237daf32 tests: Add more debug output to gdbus-threading test
It periodically hangs due to the `GDBusConnection` having more than 1
ref (and never losing them), so there’s potentially a leaking ref
somewhere:
```
(/builds/alexander.klauer/glib/_build/gio/tests/gdbus-threading:17767): GLib-GIO-DEBUG: 13:18:12.268: refcount of 0x55fe85b1a260 is not right, sleeping
\# GLib-GIO-DEBUG: refcount of 0x55fe85b1a260 is not right, sleeping
```

Add some more debug output to try and track the problem down.

See: https://gitlab.gnome.org/alexander.klauer/glib/-/jobs/1865968

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-04 19:53:04 +00:00
Philip Withnall
54ee8e5414 tests: Add more debug output to converter-stream test
It’s periodically failing on FreeBSD and I can’t reproduce the failure
locally nor work out what it is from the logs:
```
Bail out! GLib-GIO:ERROR:../gio/tests/converter-stream.c:1041:test_converter_pollable: assertion failed (res != -1): (-1 != -1)
stderr:
**
GLib-GIO:ERROR:../gio/tests/converter-stream.c:1041:test_converter_pollable: assertion failed (res != -1): (-1 != -1)
```

Add some more debug output to get the value of `error`, in the hope that
will provide some insight.

See: https://gitlab.gnome.org/GNOME/glib/-/jobs/1866486

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-04 19:51:17 +00:00
Emmanuele Bassi
0c4c8d1005 Merge branch '2611-revert-option-changes' into 'main'
Revert "gapplication: Expose zero-valued numbers in handle-local-options"

Closes #2611

See merge request GNOME/glib!2536
2022-03-04 19:21:21 +00:00
Philip Withnall
141d3f68d3 tests: Mark network-address test as expected to succeed on macOS
Commit 13c4b9579b seems to have fixed
`network-address` so that it’s reliable everywhere, including on macOS.

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

Helps: #1392
2022-03-04 19:07:02 +00:00
Philip Withnall
23e935a342 Revert "gapplication: Expose zero-valued numbers in handle-local-options"
This reverts commit 1ed67a9c44.

It turns out that including options, with their default values, in the
`handle-local-options` signal, which weren’t set on the command line,
breaks some applications.

In particular, it breaks Inkscape, which is the application this commit
was originally meant to fix (a different problem).

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

Fixes: #2611
Breaks: #2329
See: !1953
2022-03-04 18:16:12 +00:00
Philip Withnall
3bef2760e9 Merge branch 'docs' into 'main'
docs: mark macros, flags, enums with percent sign

Closes #2589

See merge request GNOME/glib!2470
2022-03-04 16:21:55 +00:00
Gabor Karsay
7e64004db0 docs: mark macros, flags, enums with percent sign 2022-03-04 16:21:55 +00:00
Philip Withnall
f08324e014 Merge branch 'w32-tests-spawn' into 'main'
Various spawn-related test fixes on win32

See merge request GNOME/glib!2485
2022-03-04 16:16:39 +00:00
Philip Withnall
674dc5171c gpowerprofilemonitor: Tweak wording of documentation to make more sense
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-04 12:18:34 +00:00
Sebastian Dröge
420238e0c4 Merge branch 'debug-controller-unused' into 'main'
gdebugcontrollerdbus: Mark a variable as G_GNUC_UNUSED

See merge request GNOME/glib!2519
2022-03-03 14:54:28 +00:00
Sebastian Dröge
8091727b27 Merge branch 'wip/pwithnall/macos-tests' into 'main'
tests: Stop ignoring test failures on macOS

See merge request GNOME/glib!2505
2022-03-03 14:53:38 +00:00
Philip Withnall
c1293acb27 gtask: Document that task name is set by g_task_set_source_tag()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-03 12:42:28 +00:00
Xavier Claessens
218ac195df meson: Add schemasdir and giomoduledir to gio dependency
This allows applications to get their value regardless whether glib is a
subproject or pkgconfig:

  gio_dep = dependency('gio-2.0')
  giomoduledir = gio_dep.get_variable('giomoduledir')
  schemasdir = gio_dep.get_variable('schemasdir')
2022-02-23 08:24:00 -05:00
Philip Withnall
dbd11f3d3b Merge branch 'wip/pwithnall/revert-2517' into 'main'
Revert "meson: Add schemasdir and giomoduledir to gio dependency"

See merge request GNOME/glib!2524
2022-02-23 12:17:29 +00:00
Philip Withnall
7f8c09cd07 Merge branch 'wip/pwithnall/network-address-test-fixes' into 'main'
tests: Remove threads from mock-resolver/network-address test

See merge request GNOME/glib!2520
2022-02-23 12:03:28 +00:00
Philip Withnall
590a2c9af8 Revert "meson: Add schemasdir and giomoduledir to gio dependency"
This reverts commit 5aa03882ca.

It fails to compile on newer Meson versions with
`--fatal-meson-warnings` due to:
```
WARNING: Project targeting '>= 0.52.0' but tried to use feature introduced in '0.54.0': variables arg in declare_dependency.
gio/meson.build:833:0: ERROR: Fatal warnings enabled, aborting
```

That happens regardless of the fact that we’ve correctly limited the use
of the `variables` argument to only when building with Meson ≥ 0.56.
Unfortunately Meson can’t statically detect that the argument is
conditional.

Bumping GLib’s Meson dependency is too much work right now, so this MR
unfortunately has to be reverted.
2022-02-23 11:51:13 +00:00
Marc-André Lureau
0f85eefb8b gio: fix OOB string access if filename is empty
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-22 23:55:57 +04:00
Philip Withnall
68dc5d5fbc Merge branch 'meson-gio-var' into 'main'
meson: Add schemasdir and giomoduledir to gio dependency

See merge request GNOME/glib!2517
2022-02-22 18:22:52 +00:00
Xavier Claessens
5aa03882ca meson: Add schemasdir and giomoduledir to gio dependency
This allows applications to get their value regardless whether glib is a
subproject or pkgconfig:

  gio_dep = dependency('gio-2.0')
  giomoduledir = gio_dep.get_variable('giomoduledir')
  schemasdir = gio_dep.get_variable('schemasdir')
2022-02-22 08:54:07 -05:00
Philip Withnall
00faa84f77 Merge branch 'giomodule' into 'main'
meson: Set GIO_EXTRA_MODULES in devenv

See merge request GNOME/glib!2518
2022-02-22 13:38:58 +00:00
Philip Withnall
13c4b9579b tests: Remove threads from mock-resolver/network-address test
`mock-resolver.c` is a mock implementation of `GResolver` used in the
`network-address` tests. It returns resolver results, and implements
timeouts, as directed by the test calling it.

In particular, it allows the IPv4 and IPv6 resolver results to be
returned using independent delays. This allows code paths which deal
with IPv4 and IPv6 results being returned at different times to be
tested, as the ‘Happy Eyeballs’ spec mandates various hard-coded
timeouts for returning the best results it can in a reasonable
timeframe.

Previously, `mock-resolver.c` implemented the timeouts by handling
`lookup_by_name()` in a `GTask` worker thread, and calling `g_usleep()`
for the timeout. This seemed to cause occasional CI failures, such as
https://gitlab.gnome.org/GNOME/glib/-/jobs/1843454, where a resolver
error would be returned rather than the expected results:
```
ok 52 /network-address/happy-eyeballs/ipv4-error-ipv6-first
\# GLib-GIO-DEBUG: IPv4 DNS error: IPv4 Broken
(/var/tmp/gitlab_runner/builds/Ff4WDDRj/0/GNOME/glib/_build/gio/tests/network-address:18428): GLib-GIO-DEBUG: 09:03:08.587: IPv4 DNS error: IPv4 Broken
Bail out! GLib-GIO:ERROR:../gio/tests/network-address.c:586:got_addr: assertion failed (error == NULL): IPv4 Broken (g-io-error-quark, 24)
stderr:
**
GLib-GIO:ERROR:../gio/tests/network-address.c:586:got_addr: assertion failed (error == NULL): IPv4 Broken (g-io-error-quark, 24)
```

While I’ve been unable to reproduce these failures locally, I suspect
they might be down to thread spawning occasionally taking long enough on
a CI runner to change the ordering of the timeouts, such that the ‘Happy
Eyeballs’ algorithm returns a different set of results from what the
test expects.

So, this commit rewrites part of `mock-resolver.c` to implement timeouts
in the main thread, rather than in a worker thread. That should
eliminate the delays in spawning threads, and should mean that the
timeout sources in `mock-resolver.c` are attached to the same
`GMainContext` as those from the ‘Happy Eyeballs’ algorithm which are
monitoring them, so a total order over the timeouts can be guaranteed.

Of course, I might be completely wrong since this is just a guess and I
can’t properly test it since I can’t reproduce the failure. Worth a try.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-22 11:25:21 +00:00
Philip Withnall
bb2d79e6a8 tests: Use g_assert_*() rather than g_assert() in network-address.c
`g_assert()` is compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-22 11:25:21 +00:00
Philip Withnall
a57706887e tests: Fix memory leaks in network-address test
The test results weren’t being freed.

This makes the `network-address` test clean under memcheck for me.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-22 11:25:21 +00:00
Philip Withnall
cd9ed612a7 gdebugcontrollerdbus: Mark a variable as G_GNUC_UNUSED
It’s not used when compiling with `G_DISABLE_ASSERT`. This fixes the CI
build failure here: https://gitlab.gnome.org/GNOME/glib/-/jobs/1843082
```
[461/1229] Compiling C object 'gio/6ae6c9e@@gio-2.0@sha/gdebugcontrollerdbus.c.o'.
FAILED: gio/6ae6c9e@@gio-2.0@sha/gdebugcontrollerdbus.c.o
cc -Igio/6ae6c9e@@gio-2.0@sha -Igio -I../gio -I. -I../ -Iglib -I../glib -Igobject -I../gobject -Igmodule -I../gmodule -I/usr/include/libmount -I/usr/include/blkid -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -Werror -std=gnu99 -g -D_GNU_SOURCE -fno-strict-aliasing -DG_ENABLE_DEBUG -DG_DISABLE_ASSERT -Wduplicated-branches -Wimplicit-fallthrough -Wmisleading-indentation -Wunused -Wno-unused-parameter -Wno-cast-function-type -Wno-pedantic -Wno-format-zero-length -Wno-variadic-macros -Werror=format=2 -Werror=init-self -Werror=missing-include-dirs -Werror=pointer-arith -Wstrict-prototypes -Wno-bad-function-cast -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=missing-prototypes -fPIC '-DG_LOG_DOMAIN="GLib-GIO"' -DGIO_COMPILATION '-DGIO_MODULE_DIR="/usr/local/lib64/gio/modules"' '-DLOCALSTATEDIR="/usr/local/var"' -fvisibility=hidden -MD -MQ 'gio/6ae6c9e@@gio-2.0@sha/gdebugcontrollerdbus.c.o' -MF 'gio/6ae6c9e@@gio-2.0@sha/gdebugcontrollerdbus.c.o.d' -o 'gio/6ae6c9e@@gio-2.0@sha/gdebugcontrollerdbus.c.o' -c ../gio/gdebugcontrollerdbus.c
../gio/gdebugcontrollerdbus.c: In function ‘authorize_cb’:
../gio/gdebugcontrollerdbus.c:345:32: error: unused variable ‘priv’ [-Werror=unused-variable]
  345 |   GDebugControllerDBusPrivate *priv = g_debug_controller_dbus_get_instance_private (self);
      |                                ^~~~
cc1: all warnings being treated as errors
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-22 09:35:40 +00:00
Xavier Claessens
0071abc187 meson: Set GIO_EXTRA_MODULES in devenv
This makes GIO find the fam module within "meson devenv" without having
to install it on the system.
2022-02-21 13:22:54 -05:00
Simon McVittie
6517bbfbc3 glocalfileinfo: Always define _g_stat_mtim_nsec, etc.
If these struct members aren't available, we can be more like an
abstraction layer by falling back to yielding 0.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-21 16:58:08 +00:00
Simon McVittie
3c12ddce81 Merge branch '1929-dbus-auth-locking' into 'main'
gdbusauthmechanismsha1: Don’t delete a stale lock file if it’s changed

Closes #1929

See merge request GNOME/glib!2511
2022-02-21 13:48:54 +00:00
Philip Withnall
36112f9b83 tests: Stop ignoring test failures on macOS
Test failures were previously ignored on macOS because there are 12
tests which consistently fail (and have not yet been fixed, because
there are no regularly active macOS maintainers for GLib; you could help
here!).

However, this means that new test failures can’t be spotted.

So, explicitly mark those 12 tests as `should_fail` on macOS, and then
make other test failures cause failure of the CI run.

We can track the process of fixing those 12 tests on #1392 and #1251.

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

Helps: #1392
2022-02-20 15:01:59 +00:00
Philip Withnall
5180c7de1e tests: Make debugcontroller and defaultvalue depend on dbus-daemon
As they use `g_test_dbus_*()`, they depend on dbus-daemon, so move them
to the part of the Meson file which lists those tests.

This disables them running on platforms which don’t have `dbus-daemon`
available. Arguably, this should be done by returning an error from
`g_test_dbus_up()` and then calling `g_test_skip()`, so the test is
correctly recorded as having been skipped. But that’s a fix for another
time.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-20 15:01:38 +00:00
Philip Withnall
ae903744ee Merge branch 'environment-test-fixes' into 'main'
tests: Fix various small memory leaks

See merge request GNOME/glib!2509
2022-02-20 12:09:00 +00:00
Philip Withnall
c60a0a45de tests: Fix a memory leak in the tls-certificate test
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-20 10:43:26 +00:00
Philip Withnall
a4ce8399cd tests: Fix memory leaks in the g-file-info-filesystem-readonly test
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-20 10:43:26 +00:00
Philip Withnall
d007fdb079 tests: Fix a memory leak in the resources test
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-20 10:43:26 +00:00
Philip Withnall
9434e4a40c tests: Use g_assert_*() rather than g_assert() in resources.c
`g_assert()` is compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-20 10:43:26 +00:00
Philip Withnall
cb18e6b969 Merge branch 'empty-argv' into 'main'
Various minor fixes for empty argv handling

See merge request GNOME/glib!2466
2022-02-20 09:36:41 +00:00
Philip Withnall
01a432d6ff glocalfileinfo: Add missing _g_stat_*() methods for win32
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-18 13:50:19 +00:00
Philip Withnall
648f9efce0 tests: Remove extra debugging from gdbus-connection-flush
Having compared the debug output, it doesn’t show anything unusual
happening that can’t already be seen from other output, for this test.

This is a partial revert of 8fd71dccc5. The debugging output it added to
other tests may still be useful.

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

Helps: #1929
2022-02-18 13:24:13 +00:00
Philip Withnall
693e4efeba tests: Use g_assert_*() rather than g_assert() in gdbus-connection-flush.c
`g_assert()` is compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-18 13:22:16 +00:00
Philip Withnall
dc0eb5e49a gdbusauthmechanismsha1: Don’t delete a stale lock file if it’s changed
The retry loop for acquiring the lock for the authentication cookie file
currently tries to acquire the lock for 0.5s, then gives up, assumes the
lock file is stale, and deletes it.

That’s great if the lock file *is* stale because it’s been left there by
a crashed process.

It’s not so great if the lock file just happens to have been there every
time this process checked, because the cookie file is highly contested
while (for example) running lots of parallel unit tests.

Check for that situation by comparing the mtime of the lock file and
continuing to retry if it’s changed.

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

Fixes: #1929
2022-02-18 13:17:19 +00:00
Philip Withnall
10e5c21102 Merge branch 'desktop-app-info-leak' into 'main'
gdesktopappinfo: Fix a leak when launching URIs over D-Bus

See merge request GNOME/glib!2510
2022-02-18 12:06:13 +00:00
Philip Withnall
3583526c2d Merge branch 'disable-assert-fix' into 'main'
gresource-tool: Fix unused-but-set-variable warn with G_DISABLE_ASSERT

See merge request GNOME/glib!2506
2022-02-18 10:38:44 +00:00
Philip Withnall
5046dd8679 Merge branch 'fix-style-check' into 'main'
codegen: Reformat parser.py according to black

See merge request GNOME/glib!2508
2022-02-18 10:38:05 +00:00
Philip Withnall
f6aafcd028 gdesktopappinfo: Fix a leak when launching URIs over D-Bus
If any platform data is set, the temporary `GVariantDict` was being
leaked.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-18 10:35:10 +00:00
Philip Withnall
d551e81812 Merge branch 'fix-compile-resources-leak' into 'main'
glib-compile-resources: Fix a memory leak of the compiler option

See merge request GNOME/glib!2501
2022-02-18 10:34:25 +00:00
Loic Le Page
c2b60e0323 Fix redefinition of local variable in gio/gdbusconnection.c 2022-02-18 11:02:05 +01:00
Loic Le Page
124733d10c Fix redefinition of local variable in gio/gnetworkservice.c 2022-02-18 11:01:41 +01:00
Loic Le Page
dd96eeee74 Fix redefinition of local variable in gio/gregistrysettingsbackend.c 2022-02-18 11:01:41 +01:00
Loic Le Page
98c1b84617 Fix redefinition of local variable and non-initialized variable in gio/gresource.c 2022-02-18 11:01:41 +01:00
Loic Le Page
2c734147cf Fix non-initialized variable in gio/gresource-tool.c 2022-02-18 11:01:41 +01:00
Loic Le Page
f92002e9f5 Fix non-initialized variable in gio/gresourcefile.c 2022-02-18 11:01:40 +01:00
Loic Le Page
37ca061e40 Fix redefinition of local variable in gio/gsettings.c 2022-02-18 11:01:40 +01:00
Loic Le Page
e0ccf08284 Fix non-initialized variable in gio/gsettings-tool.c 2022-02-18 11:01:40 +01:00
Philip Withnall
f300e883e7 codegen: Reformat parser.py according to black
This fixes the `style-check-diff` CI job.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-18 01:45:10 +00:00
Philip Withnall
425702df9c gresource-tool: Fix unused-but-set-variable warn with G_DISABLE_ASSERT
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-18 01:40:44 +00:00
Philip Withnall
9652a3dd79 gdebugcontrollerdbus: Track pending tasks with weak refs
Rather than tracking them with a counter. This should close the race in
tracking the finalisation of the tasks by the task worker thread.
There’s no way to synchronise with that thread as it’s internal to
`g_task_run_in_thread()`.

This should hopefully stop the `debugcontroller` test being flaky.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2486#note_1384102

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-18 00:46:07 +00:00
Philip Withnall
a09aca68d4 glib-compile-resources: Fix a memory leak of the compiler option
`G_OPTION_ARG_STRING` returns a newly allocated string, not a `const`
one.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-17 21:18:27 +00:00
Marc-André Lureau
9f2660fbae gio: fix OOB string access if filename is empty
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-16 18:54:03 +04:00
rim
37b39c525f Add cache to g_unix_mount_points_get() 2022-02-16 10:53:40 +00:00
Philip Withnall
c39c2a2821 Merge branch 'ebassi/issue-2601' into 'main'
Fix the DocBook codegen

Closes #2601

See merge request GNOME/glib!2489
2022-02-15 14:07:02 +00:00
Philip Withnall
b5873878cd Merge branch '1190-debugging-docs' into 'main'
gdebugcontroller: Add documentation and tests

Closes #1190

See merge request GNOME/glib!2486
2022-02-15 12:47:50 +00:00
Emmanuele Bassi
47ce6432f3 codegen: Verify that we're generating valid XML
We should output valid XML even when getting an iffy annotation.
2022-02-15 12:14:49 +00:00
Emmanuele Bassi
17f38affa2 codegen: Add missing closing angular bracket
We are matching `<parameter>` as well as `<para>`, and we
end up with broken XML in case the (expanded) description
starts with `<parameter>`.

Fixes: #2601
2022-02-15 11:51:11 +00:00
Emmanuele Bassi
6ddf760507 codegen: Remove flake8 lint rule
Using `flake8: noqa` disables ALL linting on a file. Adding
an error code does not limit the linter to that error.
2022-02-15 11:48:58 +00:00
Emmanuele Bassi
128ae2b5f5 codegen: Fix whitespace
This is Python, not C.
2022-02-15 11:48:28 +00:00
Emmanuele Bassi
fe3f699371 Add .flake8 file
The flake8 validation tool prefers an actual configuration
file to inline comments to disable the lint.
2022-02-15 11:47:30 +00:00
Philip Withnall
b7d3e3f16e tests: Add tests for GDebugController
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #1190
2022-02-14 14:42:17 +00:00
Philip Withnall
1b3e6bab53 gdebugcontrollerdbus: Add stop() method
This allows the controller to explicitly be removed from the bus, in a
way that allows the caller to synchronise with it and know that all
other references to the controller should have been dropped (i.e. after
this method returns, there should be no in-flight D-Bus calls still
holding a reference to the object).

This is needed to be able to guarantee finalisation of the controller in
unit tests (and comparable real-world situations).

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

Helps: #1190
2022-02-14 14:42:17 +00:00
Emmanuele Bassi
6c42c79d6c Use glib-compile-resource's compiler type
Since we call `glib-compile-resources` through a custom_target(), we
need to set the compiler type we're targeting.
2022-02-14 13:09:22 +00:00
Emmanuele Bassi
7bc6ef8734 Do not generate C resources for all possible toolchains
The resources data is generated for both GCC and MSVC toolchains, even
though we know beforehand which toolchain we're going to compile it for.
By dropping the data duplication we make the generated resources file
faster to compile, especially when dealing with large embedded data,
instead of relying on the C pre-processor to walk the whole file and
discard the branch we're not using.
2022-02-14 13:09:22 +00:00
Philip Withnall
11654811ef gdesktopappinfo: Add checks for empty argv
There shouldn’t be any issues here with empty argv arrays since an empty
`Exec=` line is already checked for. Encode that explicitly with an
assertion.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:42 +00:00
Philip Withnall
3ea4ba31a1 tools: Fix handling of empty argv in various minor GLib tools
This won’t really affect anything, but we might as well fix them to not
crash if called with an empty `argv` by someone (ab)using `execve()`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:42 +00:00
Philip Withnall
0d743e7ffb gapplicationcommandline: Handle the possibility empty args in an example
While it’s not usual, it is possible for applications to be called with
an empty `argv` by a process (ab)using `execve()`. Modify the
`GApplication` code example to handle that possibility, so that anyone
copying the example isn’t introducing a bug into their program
immediately.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:42 +00:00
Philip Withnall
fc6d0ba3a8 gapplicationcommandline: Fix a typo in a documentation comment
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:42 +00:00
Philip Withnall
95c6f3dc38 Merge branch '2329-application-cli-parsing' into 'main'
gapplication: Expose zero-valued numbers in handle-local-options

Closes #2329

See merge request GNOME/glib!1953
2022-02-11 12:40:37 +00:00
Philip Withnall
6d5953ee48 gdebugcontroller: Add some more documentation
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1190
2022-02-10 19:24:17 +00:00
Philip Withnall
35f6c65b35 giomodule: Ensure GDebugControllerDBus is registered
Or it’ll never work as a `GIOModule`, as the implementation won’t be
found.

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

Helps: #1190
2022-02-10 19:23:49 +00:00
Philip Withnall
a03920152f gdebugcontrollerdbus: Fix a typo in a D-Bus interface name
This was preventing `PropertiesChanged` signals from working.

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

Helps: #1190
2022-02-10 19:23:21 +00:00
Philip Withnall
29edfc1169 gdebugcontroller: Drop dup_default() method as it’s broken
If `GDebugControllerDBus` remains as the only, or default,
implementation of `GDebugController`, `dup_default()` cannot work.
`GDebugControllerDBus` requires a `GDBusConnection` at construction
time, which the `GIOModule` construction code can’t provide it.

Either we use a default D-Bus connection (but which one? and how would
it be changed by the user later if it was the wrong one?), or delegate
singleton handling of the `GDebugController` to the user.

The latter approach seems more flexible.

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

Helps: #1190
2022-02-10 19:21:24 +00:00
Philip Withnall
50d23f9680 Merge branch 'feature/move_async' into 'main'
Implement async file movement

See merge request GNOME/glib!2469
2022-02-07 14:29:52 +00:00
Lucas Schwiderski
9efde4c7fc Add test for async file move 2022-02-07 14:04:04 +00:00
Lucas Schwiderski
966f887cf9 Rename ambiguous struct 2022-02-07 14:03:47 +00:00
Lucas Schwiderski
eeb2bcf5a9 Implement async file movement 2022-02-07 14:03:47 +00:00
Zander Brown
aede29cb33 gfile: resolve_relative_path isn't nullable 2022-02-02 11:03:25 +00:00
Hu Jialun
7f044ba9c0 Amend g_bus_get* documentation regarding private connection 2022-01-28 13:11:34 +00:00
Philip Withnall
e01e6ef771 Merge branch 'windows-static-build-postfixes' into 'main'
Fix tests with static build on Windows

See merge request GNOME/glib!2442
2022-01-27 14:33:40 +00:00
Philip Withnall
cdda7bb59a Revert "Merge branch 'fix-windows-pc' into 'main'"
This reverts merge request !2459
2022-01-27 13:04:12 +00:00
Loic Le Page
38abadab3d Fix dbus process autolaunch with static build on Windows
On Windows, dbus is launched by spawning the gdbus.exe executable on
demand from the gio module. When linked dynamically, the executable
path is guessed relatively to the gio DLL path. But when linked
statically, the only reference path available is the current
executable path. In this case, gdbus.exe is not necessarily in the same
folder as the current executable.

This patch solves the issue using the same algorithm as the one used
with process spawning in glib core source code two commits above.
2022-01-27 12:10:13 +01:00
Philip Withnall
94f4ec85c6 Merge branch 'fix-memleak-gdbusauthmechanismsha1' into 'main'
Fix memory leak in gio/gdbusauthmechanismsha1.c

See merge request GNOME/glib!2461
2022-01-27 11:05:45 +00:00
Philip Withnall
7f519624e2 Merge branch '1190-debug-interface' into 'main'
gdebugcontroller: Add debug controller API and D-Bus implementation

Closes #1190

See merge request GNOME/glib!2330
2022-01-27 11:00:40 +00:00
Loic Le Page
6ec432386e Fix memory leak in gio/gdbusauthmechanismsha1.c 2022-01-27 10:39:49 +01:00
Sebastian Dröge
7f2de9ab83 Merge branch 'fix-windows-pc' into 'main'
gio: add missing zlib dependency in gio-windows-2.0.pc

See merge request GNOME/glib!2459
2022-01-27 08:45:53 +00:00
Simon McVittie
2eb1eb1649 Merge branch 'glib-compile-resources-build-improvements' into 'main'
tests: Pass --internal and -z noexecstack to glib-compile-resources tests

See merge request GNOME/glib!2456
2022-01-26 18:13:05 +00:00
Andoni Morales Alastruey
d2ab2bcefd gio: add missing zlib dependency in gio-windows-2.0.pc 2022-01-26 18:13:05 +01:00
Philip Withnall
0c8f7de55a gdebugcontroller: Add debug controller API and D-Bus implementation
This is intended to provide a uniform interface for controlling whether
the debug output from an application (or service) is emitted, typically
to journald, but actually to wherever the application chooses to output
it.

The main implementation of `GDebugController` is `GDebugControllerDBus`,
which is intended to be used on Linux. Other implementations may be
added in future for other platforms, or larger applications may want to
provide their own implementation which integrates with their ecosystem.

The `GDebugControllerDBus` implementation exposes a D-Bus interface at
`/org/gtk/Debugging` with a method to enable or disable debug
output at runtime.

This could be used by external harnesses, such as GNOME Builder or
systemd, to give a uniform way to get debug output from an application.

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

Fixes: #1190
2022-01-26 15:19:27 +00:00
Philip Withnall
9cde484b9f tests: Mark compiled resource file as not having an executable stack
As with the previous commit, this isn’t needed for GLib’s tests to work
correctly, but is probably needed in other projects which might be
tempted to copy and paste the Meson tooling from GLib.

Inspired by https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4330

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-01-26 14:28:46 +00:00
Philip Withnall
55fa866cc8 tests: Pass --internal to glib-compile-resources tests
This isn’t needed to make the tests any better (it doesn’t really affect
them), but is probably needed for anyone who copies this Meson code in
order to add `glib-compile-resources` support to their project. It’s
pretty unlikely that someone would want to compile *and export* a
resource from a shared library.

Inspired by https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4334

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-01-26 14:27:38 +00:00
Marc-André Lureau
9a9e2b5d7d gio: enable unix: address on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
e796124b31 gio: tests AF_UNIX socket credentials on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
95c3e28af5 gio: add G_CREDENTIALS_TYPE_WIN32_PID
Credentials are often used to check peer processes details.

With AF_UNIX sockets on Windows, SIO_AF_UNIX_GETPEERPID can
be used to retrive the peer PID.

We will probably introduce more advanced mechanisms later on, though,
but I am not a Windows API expert.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
568f00d65f gio/tests: enable most AF_UNIX tests on all platforms
The main difference is that g_socket_new_from_fd() requires bound
sockets on Win32.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
2f8a9196b8 gio: return G_IO_NVAL if the socket is already closed
For consistency with Unix behaviour, as checked in the tests/socket.c.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
83d45c4f35 gio: compile GUnixConnection on all platforms
On !UNIX, return an error for send_fd() & receive_fd().
(the unixfdmessage unit is not compiled on !UNIX)

The header is installed under the common GIO include directory.

Ensure G_TYPE_UNIX_CONNECTION is registered on all platforms.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
af1777d3d3 meson: compile GUnixCredentialsMessage on all platforms
The header is now also installed under the common GIO include directory.

Sorry if it breaks any build, you had to use the correct header path.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
37cab227fd gio: compile GSocketAddress with AF_UNIX on all platforms
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
3308cfb020 gio: compile GUnixSocketAddress on all platforms
Move the header under the common GIO include directory.

Sorry if it breaks any build, you had to use the correct header path.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:44 +04:00
Marc-André Lureau
4339192b53 gio: add fallback afunix.h header
afunix.h is only recently distributed with Windows SDK & MinGW.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-26 18:19:23 +04:00
Sebastian Wilhelmi
c74177337d gdbusmessage: Disallow zero-length elements in arrays
They are not allowed in the specification, and can lead to infinite
loops when parsing.

That’s a security issue if your application is accepting D-Bus messages
from untrusted peers (perhaps in a peer-to-peer connection). It’s not
exploitable when your application is connected to a bus (such as the
system or session buses), as the bus daemons (dbus-daemon or
dbus-broker) filter out such broken messages and don’t forward them.

Arrays of zero-length elements are disallowed in the D-Bus
specification: https://dbus.freedesktop.org/doc/dbus-specification.html#container-types

oss-fuzz#41428, #41435
Fixes: #2557
2022-01-26 13:04:49 +00:00
Sebastian Wilhelmi
6499ad5356 gdbusmessage: Disallow empty structures/tuples in D-Bus messages
They are disallowed in the specification:
https://dbus.freedesktop.org/doc/dbus-specification.html#container-types

Helps: #2557
2022-01-26 13:04:49 +00:00
Loic Le Page
42c77c7ac7 Enable full-static build on Windows
Glib cannot be built statically on Windows because glib, gobject and gio
modules need to perform specific initialization when DLL are loaded and
cleanup when unloaded. Those initializations and cleanups are performed
using the DllMain function which is not called with static builds.

Issue is known for a while and solutions were already proposed but never
merged (see: https://gitlab.gnome.org/GNOME/glib/-/issues/692). Last
patch is from version 2.36.x and since then the
"constructor/destructor" mechanism has been implemented and used in
other part of the system.

This patch takes back the old idea and updates it to the last version of
glib to allow static compilation on Windows.

WARNING: because DllMain doesn't exist anymore in static compilation
mode, there is no easy way of knowing when a Windows thread finishes.
This patch implements a workaround for glib threads created by calling
g_thread_new(), so all glib threads created through glib API will behave
exactly the same way in static and dynamic compilation modes.
Unfortunately, Windows threads created by using CreateThread() or
_beginthread/ex() will not work with glib TLS functions. If users need
absolutely to use a thread NOT created with glib API under Windows and
in static compilation mode, they should not use glib functions within
their thread or they may encounter memory leaks when the thread finishes.

This should not be an issue as users should use exclusively the glib API
to manipulate threads in order to be cross-platform compatible and this
would be very unlikely and cumbersome that they may mix up Windows native
threads API with glib one.

Closes #692
2022-01-26 10:14:02 +01:00
Pablo Correa Gómez
d4cbe9ce4e
xdgmime: Fix unused-variable warning
../gio/xdgmime/xdgmimemagic.c:489:24: warning:
unused variable 'i' [-Wunused-variable]
  489 |           unsigned int i;
      |                        ^
2022-01-25 20:18:41 +01:00
Philip Withnall
e00069010e Merge branch 'win32-mem-monitor' into 'main'
gio/win32: add GMemoryMonitorWin32

See merge request GNOME/glib!2452
2022-01-25 18:11:53 +00:00
Marc-André Lureau
bb1b9d90ec gio/win32: add GMemoryMonitorWin32
Windows has CreateMemoryResourceNotification() API:

https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-creatememoryresourcenotification

It only notifies whether "Available physical memory is running low."

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-25 20:55:57 +04:00
Marc-André Lureau
0ed621e905 gio/tests: use g_message to print --watch result
g_debug() isn't printed by default.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-25 16:31:10 +04:00
Marc-André Lureau
06160facf3 gio/tests: simplify enum to string in memory-monitor
Also results in more robust handling, since it can get a NULL eclass.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-25 16:31:10 +04:00
Sebastian Dröge
1979bfed4b Add (array length) annotation to g_tls_certificate_new_from_pkcs12() 2022-01-25 12:39:18 +02:00
Emmanuele Bassi
ba2725f263 tests: Check "gdbus-codegen --generate-docbook"
Verify that the command line argument works, by checking it's not writing
to stdout/stderr, and that the generated file isn't empty.
2022-01-22 01:30:16 +00:00
Emmanuele Bassi
4db9d43f1a tests: Check "gdbus-codegen --generate-rst"
Verify that the command line argument works, by checking it's not writing
to stdout/stderr, and that the generate file isn't empty.
2022-01-22 01:30:16 +00:00
Emmanuele Bassi
e2fe3aa0e7 Build the reStructuredText docs for the object-manager example
Just like we build them for the DocBook. We are not including them in the
API reference, for now.
2022-01-22 01:30:16 +00:00
Emmanuele Bassi
66e4ba806a Add reStructuredText generator to gdbus-codegen
The gdbus-codegen tool generates documentation from the XML introspection
description of a D-Bus interface. Currently, only DocBook is supported at
the moment, but not every modern documentation generator can handle that
format. The reStructuredText format is a bit more well-supported,
especially in documentation generators for non-C languages.

Unlike DocBook, we get to make our own structure and conventions for how
we structure the documentation when using reStructuredText.
2022-01-22 01:30:16 +00:00
Emmanuele Bassi
5013d08315 codegen: Do not add extra paragraph elements while parsing
When parsing a comment we're adding <para> elements ourselves, but the
DocBook generator already wraps any block of text that does not start
with a <para> element with one.
2022-01-22 01:30:16 +00:00
Philip Withnall
aad2cbd2db Merge branch 'nacho/off_t' into 'main'
giowin32: use gint64 and _lseeki64

See merge request GNOME/glib!2447
2022-01-21 13:00:25 +00:00
Ignacio Casal Quinteiro
1a34988296 _g_stat_size: return goffset
Otherwise on windows we would be capped at 32bit off_t.
2022-01-20 12:22:18 +01:00
Ignacio Casal Quinteiro
1848905a99 credentials: support the local peerpid on macos
xucred does not provide the peer pid id, but this can be fetched
from the socket LOCAL_PEERPID option. Note that we only support
it when creating the credentials from a local socket, if
the credential comes from a message over a socket the peer
pid id will not be set and -1 will be returned when trying
to get the pid for the credential.
2022-01-20 10:52:01 +01:00
Simon McVittie
cc2b28b68c Merge branch 'dbus-external-sid' into 'main'
gdbus: make client work with EXTERNAL on Windows

See merge request GNOME/glib!2429
2022-01-19 18:38:20 +00:00
Marc-André Lureau
7d7b52edbd gio: make client connection work with EXTERNAL on win32
D-Bus reference implementation doesn't require more than the claimed
process SID as part of the AUTH initial data for EXTERNAL.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-18 22:09:03 +04:00
Marc-André Lureau
e66b9489b7 gio: re-use win32 SID helpers
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-18 22:08:16 +04:00
Maximiliano Sandoval R
525f20a247 docs: Replace broken link 2022-01-18 13:48:43 +00:00
Maximiliano Sandoval R
7118c16347 docs: Improve docs for gdbusutils.c 2022-01-18 13:48:43 +00:00
Marc-André Lureau
d4a66baadb gio: add win32 SID helper functions
The code is based from #1351 patch and existing similar code in
gdbusprivate.c. The next commit will replace that existing code with
those helpers.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-18 17:40:02 +04:00
Philip Withnall
ea18fcff58 Merge branch 'mwleeds/fix-codegen-typo' into 'main'
gdbus-codegen: Fix a typo in a comment

See merge request GNOME/glib!2426
2022-01-17 15:38:50 +00:00
Phaedrus Leeds
6342922d27 gdbus-codegen: Fix a typo in a comment 2022-01-11 20:03:13 -08:00
Patrick Griffis
96ce3feeb9 gtlscertificate: Add ability to load PKCS #12 encrypted files
This depends on the GTlsBackend implementing these properties
2022-01-07 11:27:56 -06:00
Ralf Habacker
229f7d4a03 Fix cross build error for Windows with gcc
This commit puts an additional underscore before the external symbol
`_g_binary_test1_resource_data` when using gcc for Windows, to match
the compiler's expectation.

Fixes #2571

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-01-06 09:20:54 +01:00
Kelvin Zhang
2a4422b0f2 Use meson dependency to link against apple framework
Using ld_flags would work, but that does not propagate ldflags to users
of glib. Meson's dependency() call will propagate apple framework
dependencies to downstream users.
2022-01-05 11:32:32 -08:00
Andy Russell
82ece18644
annotate g_content_type_guess parameter as filename 2021-12-28 15:36:54 -05:00
Philip Withnall
954a8724c2 xdgmime: Add missing S_ISREG definitions for VS2022
Otherwise building with VS2022 fails with:
```
Creating library D:/temp/29/.sw/out/323969/gnome.glib.gio-2.71.0.lib and object D:/temp/29/.sw/out/323969/gnome.glib.gio-2.71.0.exp
xdgmime.c.4b279509.obj : error LNK2019: unresolved external symbol S_ISREG referenced in function _gio_xdg_get_mime_type_for_file
xdgmimecache.c.79af418f.obj : error LNK2001: unresolved external symbol S_ISREG
D:\temp\29\.sw\out\323969\gnome.glib.gio-2.71.0.dll : fatal error LNK1120: 1 unresolved externals
```

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

Fixes: #2560
2021-12-23 12:35:48 +00:00
Philip Withnall
4d6da4457a gthreadedresolver: Tighten up types and constness of parsing code
Not everything should be an int. This code is quite dated. We now try to
use `guint8*` to represent arbitrary binary data, rather than `guchar*`
(which makes it sound like some form of string).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-12-15 17:04:20 +00:00
Patrick Griffis
49e667d250 gthreadedresolver: Export g_resolver_records_from_res_query()
While it’s not a supported public part of the API, exporting this
symbol from the library means we can easily test the DNS record parser,
which is important to do since it handles untrusted data from the
network.
2021-12-15 16:55:01 +00:00
Michael Catanzaro
376e2915e2 Add test for child_err_report_fd conflation with target fds
This tests for glib#2506.
2021-12-14 13:47:31 -06:00
Michael Catanzaro
d4c486779d Add tests for GSubprocess fd conflation issues
This tests for #2503. It's fragile, but there is no non-fragile way to
test this. If the test breaks in the future, it will pass without
successfully testing the bug, not fail spuriously, so I think this is
OK.
2021-12-14 13:47:31 -06:00
Michael Catanzaro
2a7547f8a5 gsubprocess: ensure we test fd remapping on the posix_spawn() codepath
We should run test_pass_fd twice, once using gspawn's fork/exec codepath
and once attempting to use its posix_spawn() codepath. There's no
guarantee we'll actually get the posix_spawn() codepath, but it works
for now on Linux.

For good measure, run it a third time with no flags at all.

This causes the test to fail if I separately break the fd remapping
implementation. Without this, we fail to test fd remapping on the
posix_spawn() codepath.
2021-12-14 13:45:39 -06:00
Philip Withnall
f493d3fd24 Merge branch 'cxx-test' into 'main'
Removing redundant cxx test tests/cxx-test.cpp

See merge request GNOME/glib!2391
2021-12-14 15:23:16 +00:00
Emmanuel Fleury
ae345e56c2 Distribute cxx test tests/cxx-test.cpp to each module tests directory
tests/cxx-test.cpp is removed and splitted into gio/tests/cxx.cpp,
gmodule/tests/cxx.cpp and gobject/tests/cxx.cpp.

Helps issue #1434
2021-12-14 14:43:03 +01:00
Ivaylo Dimitrov
f065497acf GDesktopAppInfo: Try to always correctly set id
Specs say that on Unix id should be desktop file id from the xdg menu
specification, however, currently code just uses basename of .desktop file.
Fix that by finding the .desktop file in all the desktop_file_dirs and use
basename only as a fallback.

See https://specifications.freedesktop.org/menu-spec/latest/go01.html#term-desktop-file-id
and https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s02.html#desktop-file-id

"To determine the ID of a desktop file, make its full path relative to the
$XDG_DATA_DIRS component in which the desktop file is installed, remove the
"applications/" prefix, and turn '/' into '-'."

Also, add unit test that verifies Desktop Id is being correctly set

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
2021-12-14 11:46:57 +00:00
Philip Withnall
72377e3b6e Merge branch 'new_alloca0_newa0' into 'main'
galloca: Add new API g_alloca0 and g_newa0

Closes #475

See merge request GNOME/glib!2367
2021-11-26 12:38:46 +00:00
Nishal Kulkarni
48d0d9f76b gsocket: Use new g_alloca0() function
Replace `g_alloca()` and `memset()` with `g_alloca0()`
2021-11-26 12:24:23 +00:00
Sebastian Dröge
5fcd2495f9 De-duplicate g_nearest_pow() implementation
And put it as static inline function into a private shared header instead.
2021-11-25 14:05:42 +02:00
Michael Catanzaro
f877b82573 gresolver: add missing locking
This is sad, but GResolver has one member variable for historical
reasons, to implement the reload signal. Since it offers a global
singleton, we should make sure it's really safe to use from multiple
threads at once.
2021-11-24 09:16:11 -06:00
Michael Catanzaro
6eb741a6ac gresolver: rename internal reload function
Since there is not actually anything to reload, let's just say we emit
the reload signal.
2021-11-24 09:16:11 -06:00
Michael Catanzaro
c2b5fe9f2d gresolver: remove unneeded call to res_init()
This call was needed once upon a time, when GResolver had subclasses
that presumably relied on this. Nowadays, we have only
GThreadedResolver, which does not need it. res_init() is dangerous
because it modifies global state, so let's get rid of it.
2021-11-24 09:16:11 -06:00
Nirbheek Chauhan
ed7c3dd343 Merge branch 'wip/pwithnall/freebsd-objcopy-fix-why-oh-why' into 'main'
tests: Allow `objcopy --help` to fail, because it fails on FreeBSD

See merge request GNOME/glib!2364
2021-11-24 15:12:15 +00:00
Luca Bacci
de6da5aa73
GWin32AppInfo: Implement should_show vfunc 2021-11-24 15:48:10 +01:00
Luca Bacci
ebddb60e3e
Add vfunc checks in gappinfo.c
Fixes crashes caused by calling unimplemented vfuncs on Windows
2021-11-24 15:06:46 +01:00
Philip Withnall
dc243a5113 tests: Allow objcopy --help to fail, because it fails on FreeBSD
This is a partial revert of b248f3481c. Eventually, this commit can be
dropped once `objcopy --help` doesn’t exit with a non-zero status on
FreeBSD.

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2360#note_1318608

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-24 12:01:39 +00:00
Philip Withnall
6bdb06ff4b Merge branch 'run_command-check' into 'main'
meson: specify when commands need to succeed in run_command

See merge request GNOME/glib!2360
2021-11-24 10:31:41 +00:00
Eli Schwartz
b248f3481c
meson: specify when commands need to succeed in run_command
meson in git master now warns about a missing `check:` kwarg, and may
eventually change the default from false to true.

Take the opportunity to require `objcopy --help` to succeed -- it is
unlikely to fail, but if it does something insane happened.
2021-11-24 00:31:18 -05:00
Aleksandr Mezin
bff4db527e gdbusproxy: Make 'g-signal' signal detailed
Fixes #2536
2021-11-23 22:14:19 +06:00
Philip Withnall
56b0b8069d Merge branch 'dbus-daemon-print-address-fd' into 'main'
gtestdbus: Print the dbus address on a specific FD intead of stdout

Closes #2537

See merge request GNOME/glib!2354
2021-11-23 13:32:24 +00:00
Marco Trevisan (Treviño)
d98a52254b gtestdbus: Print the dbus address on a specific FD intead of stdout
We used to use a pipe for the dbus daemon stdout to read the defined
address, but that was already requiring a workaround to ensure that dbus
daemon children were then able to write to stdout.
However the current implementation is still causing troubles in some
cases in which the daemon is very verbose, leading to hangs when writing
to stdout.

As per this, just don't handle stdout ourself, but use instead a
specific pipe to get the address address. That can now be safely closed
once we've received the data we need.

This reverts commit d80adeaa96.

Fixes: #2537
2021-11-23 13:07:50 +00:00
Philip Withnall
1f8390c002 gdbusmessage: Remove arbitrary restriction on minimum D-Bus blob length
The code in `g_dbus_message_new_from_blob()` has now been fixed to
correctly error out on all truncated messages, so there’s no need for an
arbitrary programmer error if the input is too short to contain a valid
D-Bus message header.

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

Helps: #2528
2021-11-23 12:57:29 +00:00
Sebastian Wilhelmi
c58be7d569 tests: Add test cases for truncated D-Bus messages
(Minor code formatting tweaks and leak fixes by Philip Withnall.)

Helps: #2528
2021-11-23 12:55:00 +00:00
Sebastian Wilhelmi
4b9a27a868 gdbusmessage: Add more bounds checking when parsing D-Bus messages
Perform strict bounds checking when reading data from the D-Bus message,
and propagate errors to the callers.

Previously, truncated D-Bus messages could cause out-of-bounds reads.

This is a security issue, but one which is only exploitable when
communicating with an untrusted peer (who might send malicious
messages). Almost all D-Bus traffic is with a session or system bus,
where the dbus-daemon or dbus-broker is trusted, and is known to have
already rejected malformed (malicious) messages.

Accordingly, this is only exploitable with peer-to-peer D-Bus
conversations with an untrusted peer.

(Includes some minor cleanups from Philip Withnall.)

oss-fuzz#17408
Fixes: #2528
2021-11-23 12:32:31 +00:00
Michael Catanzaro
82999879bc gtlsconnection: warn about footguns of using a non-default database
Since
https://gitlab.gnome.org/GNOME/glib-networking/-/merge_requests/173,
there is now a really surprising implication to using a non-default
GTlsDatabase: your database could do nothing at all other than wrap the
default database, which you would expect to result in no behavior
changes, but in fact it causes fewer security checks to be performed
during certificate verification. This is because certificate
verification moved from GTlsDatabase to GTlsConnection, allowing for
more security checks to be performed. But if using a non-default
GTlsDatabase, we have to fall back to letting GTlsDatabase to the
verification, as before.

This is the best we can do. It's not a regression for applications,
because it means applications get the previous pre-2.72 behavior. But it
does mean that new security checks added in 2.72 are not applied, which
is unfortunate, so we should warn developers about this.
2021-11-22 15:56:56 +00:00
Michael Catanzaro
a6a41cfc17 gtlscertificate: tone down warning about g_tls_certificate_verify() 2021-11-22 15:56:56 +00:00
Michael Catanzaro
5f585225a2 gtlsdatabase: tone down warning about g_tls_database_verify_chain()
This is only true for the default GnuTLS backend. It is not true for the
OpenSSL backend, so let's say "may" instead of "will."
2021-11-22 15:56:56 +00:00
Michael Catanzaro
3b3d56a45c gtlsdatabase: remove stray "Since: 2.70"
This feature has been reverted for now because I messed up the
implementation and it was doing sync I/O during async API calls. Oops!
Since it's not present in 2.70 nor in 2.72, let's remove the reference
to the exact GLib version that this behavior was introduced in. I'd like
to get it working properly for 2.74, but it's not ready yet and just
changing the version to 2.74 feels optimistic.
2021-11-22 15:56:56 +00:00
Sebastian Dröge
6d8045ddb4 Merge branch 'gdbus-call-interactive' into 'main'
gdbus: Add --interactive option to `gdbus call`

See merge request GNOME/glib!2329
2021-11-22 13:58:46 +00:00
Philip Withnall
8e185e12c9 tests: Fix a flaky wait in converter-stream
Rather than waiting for a fixed period of time, poll in a loop until the
condition the test is expecting is true.

A better solution would be to use a `GSource` and wait until that’s
dispatched. But doing so might affect the behaviour of the
`GInputStream` under test, so busy-wait instead.

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

```
(some socket debug output)
Bail out! GLib-GIO:ERROR:../gio/tests/converter-stream.c:1037:test_converter_pollable: assertion failed (res == -1): (1 == -1)
```

I could not reproduce the failure remotely with a few hundred
invocations of the test, so it might only present itself on BSD, which
presumably has different socket timing behaviour from Linux.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-22 13:22:25 +00:00
Philip Withnall
40037ebbfc tests: Use g_assert_*() rather than g_assert() in converter-stream.c
`g_assert()` is compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-22 13:20:17 +00:00
Alexander Kanavin
e161c62292 gio/tests/codegen.py: bump timeout to 100 seconds
This may be necessary on overloaded CI systems.
2021-11-18 14:07:11 +01:00
Frederic Martinsons
296a8c6522 Sort output of gsettings command-line tool
Closes #1781

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-11-18 08:59:55 +01:00
Philip Withnall
b09ccc4635 Merge branch 'fix_all_warnings' into 'main'
Fix final warnings in Windows code

See merge request GNOME/glib!2323
2021-11-17 15:15:46 +00:00