Commit Graph

26113 Commits

Author SHA1 Message Date
Matthias Clasen
e79af74d1b gobject: Always ref-sink variants in g_object_set
When collecting varargs, ignore the NOCOPY_CONTENTS
flag for variants. That is what our docs advice for
refcounted types, and it fixes a regression that
was inadvertendly introduced when we stopped doing
some extra GValue copies.

Includes a test case by Philip Withnall.

Fixes: #2774
2022-10-24 10:47:35 +01:00
Simon McVittie
662661a8d0 Merge branch 'wip/pwithnall/macos-file-info-test-fixed' into 'main'
build: Mark the g-file-info test as succeeding

See merge request GNOME/glib!3004
2022-10-21 18:56:12 +00:00
Marco Trevisan
d83c87c1f6 Merge branch 'gdbus-server-no-abstract-tmpdir' into 'main'
Fix sandbox escape in GDBusServer

See merge request GNOME/glib!3005
2022-10-21 16:09:12 +00:00
msizanoen1
9151fe94cb gio: remove pointless use of g_unix_socket_address_abstract_names_supported with unix:tmpdir=
There's no point in checking for
g_unix_socket_address_abstract_names_supported now that unix:tmpdir=
always use non-abstract sockets.
2022-10-21 22:09:06 +07:00
msizanoen1
c0a1a3b384 gio/gdbusserver: use non-abstract socket for unix:tmpdir=
This implements https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/350
for GDBus's server implementation.

Abstract sockets belong to the network namespace instead of the mount
namespace. As a result, mount namespace-based sandboxes (e.g. Flatpak)
cannot restrict access to abstract sockets (and therefore GDBus's
unix:tmpdir= server addresses), at least for applications with network
access permission, which may result in sandbox escapes unless the
application running the GDBus server explicitly check that the connecting
process is not in a sandbox. As of the time of writing, no known
applications using GDBusServer does this.

Fix this by always using non-abstract sockets for unix:tmpdir=, which is
allowed by the DBus specification.
2022-10-21 22:08:11 +07:00
Philip Withnall
d0eaccccad build: Mark the g-file-info test as succeeding
Previously it was marked as failing on macOS, but commit
ed3998b390 seems to have fixed that. yay!

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

Helps: #1392
2022-10-21 15:48:33 +01:00
Emmanuele Bassi
86430a27d2 Merge branch 'time' into 'main'
gio/tests/g-file-info: don't assume million-in-one events don't happen

See merge request GNOME/glib!2990
2022-10-20 15:11:56 +00:00
Philip Withnall
2365452d6e Merge branch 'allow-mixed-declarations' into 'main'
meson: Don't explicitly disable mixed declarations and statements

See merge request GNOME/glib!2951
2022-10-20 14:32:23 +00:00
Ross Burton
ed3998b390 gio/tests/g-file-info: don't assume million-in-one events don't happen
The access and creation time tests create a file, gets the time in
seconds, then gets the time in microseconds and assumes that the
difference between the two has to be above 0.

As rare as this may be, it can happen:

$ stat g-file-info-test-50A450 -c %y
2021-07-06 18:24:56.000000767 +0100

Change the test to simply assert that the difference not negative to
handle this case.

This is the same fix as 289f8b, but that was just modification time.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2022-10-20 14:41:56 +01:00
Philip Withnall
1db9066485 Merge branch 'fix-gstrerror-warning' into 'main'
gstrfuncs: Fix a compiler warning in g_strerror()

See merge request GNOME/glib!2956
2022-10-20 12:36:27 +00:00
Philip Withnall
4dcb7f1f9f Merge branch '2753-vasprintf-loop' into 'main'
gprintf: Avoid an infinite loop on ENOMEM in g_vasprintf()

Closes #2753

See merge request GNOME/glib!2944
2022-10-20 12:29:11 +00:00
Marco Trevisan
e49c4b1a9e Merge branch 'python-code-style-again' into 'main'
tests: Fix code style in Python files to satisfy black and flake8

See merge request GNOME/glib!2984
2022-10-20 11:59:53 +00:00
Michael Catanzaro
21a784920d Merge branch 'th/gspawn-no-safe-close' into 'main'
gspawn: avoid race due to retry with EINTR on close()

See merge request GNOME/glib!2947
2022-10-20 11:55:08 +00:00
Philip Withnall
e6fa40bf99 Merge branch 'wip/3v1n0/add-darwin-os' into 'main'
meson: Define G_OS_DARWIN when compiling under OSX or iOS

See merge request GNOME/glib!2981
2022-10-20 11:41:48 +00:00
Philip Withnall
5b01b47c34 Merge branch 'gicon-introspect-vfuncs' into 'main'
gicon: Add introspection for to_tokens / from_tokens vfunc's

See merge request GNOME/glib!2937
2022-10-20 11:39:04 +00:00
Thomas Haller
d6790aecca gspawn: use g_close()
g_close() now is async-signal-safe, as long as we don't request a GError
and pass a valid file descriptor.

Update "gspawn.c" to drop its safe_close() function and use
g_close() instead.
2022-10-20 08:16:52 +02:00
Thomas Haller
3ed7f4d1ed gstdio: make g_close() async-signal-safe under certain conditions
g_close() does something useful. It is not trivial to get EINTR handling of
close() right, in a portable manner. g_close() abstracts this.

We should allow glib users to use the function even in async-signal-safe
contexts, at least if the user heeds the caveat about GError and take care
not to fail assertions.
2022-10-20 08:16:38 +02:00
Marco Trevisan (Treviño)
476e33c3f3 gio, glib: Use G_OS_DARWIN for code that is for such environments
While we preserved the COCOA/CARBON cases when specific libraries are
needed.
2022-10-20 03:37:21 +02:00
Marco Trevisan (Treviño)
e85635daa0 meson: Define G_OS_DARWIN when compiling under OSX or iOS
It has enough differences to expose it as an unix-subtype.
2022-10-20 03:37:03 +02:00
Thomas Haller
6418db829b gspawn: avoid race due to retry with EINTR on close()
Retry on EINTR is wrong on many OS, including Linux. See the comment
in g_close() why that is.

As we cannot use g_close() after fork, we had safe_close(). This had the
wrong retry loop on EINTR. Drop that.

This was especially problematic since commit 6f46294227 ('gspawn: Don’t
use g_close() in async-signal-safe context'). Before, safe_close() was
only called after fork, where there is only one thread and there is no
concern about a race.

This patch only exists for easier backporting of the bugfix. The code
will be reworked further next.

Fixes: 6f46294227 ('gspawn: Don’t use g_close() in async-signal-safe context')
2022-10-19 20:54:18 +02:00
Philip Withnall
06029c5945 Merge branch 'remove-docs-artifacts' into 'main'
ci: Do not store docs artifacts

See merge request GNOME/glib!2985
2022-10-19 18:21:51 +00:00
Matthias Clasen
65536b079d gstrfuncs: Fix a compiler warning in g_strerror()
MSVC is complaining about this code. Let’s try
to help it see the light.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2800
2022-10-19 14:53:45 +01:00
Marco Trevisan (Treviño)
782625bd26 ci: Do not store docs artifacts
This was discussed in a previous MR [1], but it apparently went in
during rebase

[1] https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2820#note_1502207
2022-10-19 15:52:22 +02:00
Philip Withnall
4b6cc2d87b Merge branch 'gtask-bitfields-fix' into 'main'
gtask: Use unsigned bit-field struct values to avoid warnings

See merge request GNOME/glib!2979
2022-10-19 11:32:25 +00:00
Philip Withnall
59541e335a tests: Fix code style in Python files to satisfy black and flake8
This should make the style-check-diff CI job happy again.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-10-19 12:28:08 +01:00
Philip Withnall
08cb200aec Merge branch 'halfline-no-spawn' into 'main'
A couple of test fixes on OS X

See merge request GNOME/glib!2978
2022-10-19 10:20:34 +00:00
Philip Withnall
7cc95e0211 Merge branch 'wip/pwithnall/2785-macos-fd-close-test-failure' into 'main'
gstdio: Temporarily disable g_close() warning on macOS

See merge request GNOME/glib!2977
2022-10-19 09:52:29 +00:00
Philip Withnall
0839556904 Merge branch 'gmessages-handle-unused-write-results' into 'main'
gmessages: Handle unused results from fputs and fwrite

Closes #2758

See merge request GNOME/glib!2910
2022-10-19 09:23:52 +00:00
Ray Strode
8f85fa163b tests: Check for public.text not text/plain on OSX
The "content type" on OSX is a Uniform Type Identifier not a MIME
type, so make sure to use the right format in the empty file test.
2022-10-18 16:02:49 -04:00
Ray Strode
9d0d30c9d2 tests: Don't run du on osx
The du command that ships on OS X doesn't understand
--bytes, so don't try to use du on that platform.
2022-10-18 16:02:02 -04:00
Marco Trevisan (Treviño)
4398d140c7 gtask: Use unsigned bit-field struct values to avoid warnings
In recent Clang we may get a build warning as per:

  ../gio/gtask.c: warning: implicit truncation from 'int' to a
    one-bit wide bit-field changes value from 1 to -1
    [-Wsingle-bit-bitfield-constant-conversion]

This is because we use gboolean (and thus a signed type) for bit-fields.
Now, this is not an issue in practice for the way we're using them, but
still better to mute such compiler warns in the right way.
2022-10-18 21:28:00 +02:00
Ray Strode
11ca3da091 Merge branch 'halfline/test-case-pipe-confusion' into 'main'
tests/desktop-app-info: Make sure scripts writes to the right end of the pipe

See merge request GNOME/glib!2969
2022-10-18 17:57:52 +00:00
Marco Trevisan (Treviño)
977b734e0b gmessages: Handle unused results from fputs and fwrite
Fixes: #2758
2022-10-18 19:41:18 +02:00
Marco Trevisan
ba961b90d9 Merge branch 'log-fallback-handler-newline' into 'main'
gmessages: Add missing trailing newline in fallback log handler

See merge request GNOME/glib!2945
2022-10-18 16:38:59 +00:00
Marco Trevisan
2c90a563ae Merge branch 'unix-streams-fixes' into 'main'
tests: Fix race condition on cancellation in unix-streams test

See merge request GNOME/glib!2963
2022-10-18 16:30:19 +00:00
Marco Trevisan
337763bcf3 Merge branch 'always-sniff-xdg-mime' into 'main'
glocalfileinfo: Ensure we always sniff some data to get the content type

Closes #2742

See merge request GNOME/glib!2887
2022-10-18 16:27:25 +00:00
Ray Strode
04c8a6bc61 Revert "tests: Temporarily disable desktop-app-info terminal test on FreeBSD"
Since we no longer require /proc for the desktop-app-info test, we can
run it on FreeBSD again.

This reverts commit 3235eee0e2.
2022-10-18 12:15:10 -04:00
Ray Strode
4657e9bf60 tests/desktop-app-info: Use named pipe instead of /proc
Freebsd doesn't always have /proc mounted, so relying on
/proc for the tests isn't ideal.

This commit changes the desktop-app-info tests to use
mkfifo instead of /proc/../fd/.. to relay terminal
arguments.

Might help with this error message I'm seeing in CI:

/tmp/bin-path-H1UQT1/gnome-terminal: cannot create /proc/38961/fd/6: No such file or directory
2022-10-18 12:15:10 -04:00
Marco Trevisan (Treviño)
846e68befd glocalfileinfo: Ensure we always sniff some data to get the content type
In case the XDG database is not initialized yet we may try to sniff a
0-length data, making our content-type routines to mark non-empty files
as `application/x-zerosize`.

This is wrong, so in case the sniff size is not set, let's just
try to read the default value. To avoid false-application/x-zerosize
results (that are not something we want as per legacy assumptions).

See: https://bugzilla.gnome.org/show_bug.cgi?id=755795

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2742
2022-10-18 17:46:38 +02:00
Marco Trevisan
066ca6b042 Merge branch 'coverity-issues' into 'main'
Fix a couple of minor Coverity issues

See merge request GNOME/glib!2976
2022-10-18 15:03:06 +00:00
Philip Withnall
9965d0cdc7 Merge branch '2782-gvariant-recursion-typedecl-fix' into 'main'
gvariant-parser: Reject deeply-nested typedecls in text form variants

Closes #2782

See merge request GNOME/glib!2974
2022-10-18 14:50:25 +00:00
Marco Trevisan
baa766295d Merge branch 'fix-desktop-app-info' into 'main'
tests: Fix minor race in desktop-app-info terminals test

See merge request GNOME/glib!2968
2022-10-18 14:44:42 +00:00
Philip Withnall
5190354ad9 gstdio: Temporarily disable g_close() warning on macOS
It causes the tests to fail, which suggests some latent FD handling bug
on macOS (but not other platforms).

Unfortunately I’m unable to debug that due to not having access to a
macOS machine, and it’s blocking CI for the rest of the project.

So disable it on macOS for now, until someone with access to a macOS
machine can take a look.

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

Helps: #2785
2022-10-18 15:41:30 +01:00
Marco Trevisan
f8674c1d4c Merge branch 'g_str_has_optimization' into 'main'
Optimize g_str_has_*() functions to  detect static arguments

Closes #24

See merge request GNOME/glib!2859
2022-10-18 14:15:56 +00:00
Philip Withnall
ab774d6e8b gbinding: Explicitly ignore return values from g_param_value_validate()
They only indicate whether the value had to be modified to keep it
valid. That doesn’t matter when binding values.

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

Coverity CID: #1498116, #1498114
2022-10-18 15:12:31 +01:00
Philip Withnall
4fca3bba8f gregex: Remove an unreachable return statement
Spotted by Coverity.

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

Coverity CID: #1497916
2022-10-18 15:05:30 +01:00
Philip Withnall
3e313438f1 gvariant-parser: Reject deeply-nested typedecls in text form variants
Return `G_VARIANT_PARSE_ERROR_RECURSION` from `g_variant_parse()` if a
typedecl is found within a text-form variant which would cause any part
of the variant to exceed the maximum allowed recursion/nesting depth.

This fixes an oversight when `G_VARIANT_MAX_RECURSION_DEPTH` was
implemented, which allowed typedecls to effectively multiply the size of
an array if `g_variant_parse()` was parsing a text-form variant without
a top-level concrete type specified.

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

Fixes: #2782
oss-fuzz#49462
2022-10-18 14:52:32 +01:00
Philip Withnall
9164fdcbbb Merge branch 'mcatanzaro/cast-checks-oopsie' into 'main'
Fix build when G_DISABLE_CAST_CHECKS is defined to empty string

See merge request GNOME/glib!2967
2022-10-18 13:45:03 +00:00
Ray Strode
2e627803e7 Merge branch 'fix-GTimeZone-in-toolbx' into 'main'
gtimezone: Reject weird /etc/localtime configurations

See merge request GNOME/glib!2955
2022-10-18 13:39:44 +00:00
Philip Withnall
8d02465ea8 Merge branch 'th/hash-steal-doc' into 'main'
ghash: comment g_hash_table_steal_extended() about not destroying key/value

See merge request GNOME/glib!2965
2022-10-18 13:37:14 +00:00