5521 Commits

Author SHA1 Message Date
Philip Withnall
4624fc06ba gdbusmessage: Check for valid GVariantType when parsing a variant blob
The code was checking whether the signature provided by the blob was a
valid D-Bus signature — but that’s a superset of a valid GVariant type
string, since a D-Bus signature is zero or more complete types. A
GVariant type string is exactly one complete type.

This meant that a D-Bus message with a header field containing a variant
with an empty type signature (for example) could cause a critical
warning in the code parsing it.

Fix that by checking whether the string is a valid type string too.

Unit test included.

oss-fuzz#9810

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 12:06:51 +00:00
Philip Withnall
2a42110353 gdbusmessage: Fix a typo in a documentation comment
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 12:06:51 +00:00
Philip Withnall
90a1df4949 gdbusmessage: Clarify error returns for g_dbus_message_new_from_blob()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 12:06:51 +00:00
Philip Withnall
2b1d4eb08c gdbusmessage: Improve documentation for g_dbus_message_get_header()
The caller is responsible for checking the type of the returned
GVariant.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 12:06:51 +00:00
Philip Withnall
02dabf96ac gdbusmessage: Validate type of message header signature field
Parsing a D-Bus message with the signature field in the message header
of type other than ‘g’ (GVariant type signature) would cause a critical
warning. Instead, we should return a runtime error.

Includes a test.

oss-fuzz#9825

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 12:06:51 +00:00
Philip Withnall
4d2405dc7f Merge branch '420-codegen-autoptr-glib-2-58' into 'glib-2-58'
gdbus-codegen: add autocleanup for FooObject (backport to glib-2-58)

See merge request GNOME/glib!428
2018-11-06 10:43:34 +00:00
Simon McVittie
a11ff3755a meson: Centralize test timeout values
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-01 19:09:41 +00:00
Ondrej Holy
aa5b7206e0 glocalfile: Use MAXSYMLINKS when following symlinks
Currently, readlink() is used only 12 times when expanding symlinks.
However, kernel uses 40 for this purpose and it is defined as MAXSYMLINKS.
Use that constant if available, or 40. See:
https://github.com/torvalds/linux/include/linux/namei.h.
2018-10-30 11:47:23 +00:00
Ondrej Holy
012646ce6b glocalfile: Return NULL if symlink expansion fails
find_mountpoint_for() uses current file in case of error, because
get_parent() returns NULL for error, but also if parent doesn't exist.
Return "." from get_parent() if parent doesn't exist in order to
differentiate the error state.
2018-10-30 11:47:23 +00:00
Ondrej Holy
92f7592ec0 glocalfile: Add test case for symlink expansion
Test symlink expansion in find_mountpoint_for() function over
 _g_local_file_find_topdir_for(). find_mount_for() is crucial for many
of glocalfile.c functionality (e.g. to determine correct trash location)
and symlink expansion has to work properly.

https://gitlab.gnome.org/GNOME/glib/issues/1522
2018-10-30 11:47:23 +00:00
Ondrej Holy
d565484a6a glocalfile: Fix bug uri in trash test
Fix typo in g_test_bug_base and move g_test_bug in the concrete test.
2018-10-30 11:47:23 +00:00
Ondrej Holy
e573582293 glocalfile: Fix access::can-trash if parent is symlink
G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH can be set to a wrong value if
its parent dir is a symlink. This is because the find_mountpoint_for()
function tries to find mountpoint for a filepath and expands symlinks
only in parent dirs. But in this case the path is already parent dir
and needs to be expanded first...

Closes: https://gitlab.gnome.org/GNOME/glib/issues/1522
2018-10-30 11:47:23 +00:00
Will Thompson
1fcdf88c45 gdbus-codegen: add autocleanup for FooObject
This is only enabled with `--c-generate-autocleanup all` for the
reasons discussed on https://bugzilla.gnome.org/show_bug.cgi?id=763379.
2018-10-29 23:16:42 +00:00
Will Thompson
9b4eddff0c gdbus-codegen: test generating autocleanups
This is the most degenerate possible test but it does exercise this code
path.

(Tweaked by Philip Withnall <withnall@endlessm.com> to also add the flag
to the autotools build.)
2018-10-29 23:16:42 +00:00
Marco Trevisan
4f14e614fa Merge branch 'gdbus-peer-again' into 'master'
gdbus-peer: Make sure to not include objectmanager-gen.c source

See merge request GNOME/glib!416

(cherry picked from commit 4d48e020278b6be64ba84be7b8ab388f5ff2b358)

7c70bef8 gdbus-peer: Make sure to not include objectmanager-gen.c source
2018-10-25 12:35:04 +00:00
Philip Withnall
c5ea31846f Merge branch 'objectmanager-src-dep' into 'master'
gio, tests: ensure objectmanager sources are generated

See merge request GNOME/glib!414

(cherry picked from commit 5263b54a06d6289cf8bbaa7870e1eed8b4cd8626)

11e4fcca gio, tests: ensure objectmanager sources are generated
2018-10-25 12:32:28 +00:00
Simon McVittie
f86cdf7d11 Merge branch 'backports-glib-2-58' into 'glib-2-58'
A couple of minor glib-2-58 backports

See merge request GNOME/glib!409
2018-10-23 10:05:56 +00:00
Philip Withnall
1161ac3bdb Merge branch 'wip/oholy/bind-mounts-stable' into 'glib-2-58'
gunixmounts: Filter out mounts with device path that was repeated

See merge request GNOME/glib!365
2018-10-23 01:53:30 +00:00
Colin Walters
452eb1df01 build-sys: Pass CFLAGS to $(DTRACE)
Fedora is using https://fedoraproject.org/wiki/Changes/Annobin
to try to ensure that all objects are built with hardening flags.
Pass down `CFLAGS` to ensure the SystemTap objects use them.
2018-10-23 14:28:14 +13:00
Xavier Claessens
a03083ee17 Meson: Fix linking of gdbus-peer test 2018-10-19 10:34:02 -04:00
Ondrej Holy
ed88b23fdf gunixmounts: Filter out mounts with device path that was repeated
libmount-based implementation doesn't filter out mounts with device
path that was repeated as it is done with mntent-based implementation.
It causes problems to our volume monitors which are not able to handle
multiple mounts for one device path properly without additional API.
Let's filter out the same mounts as are filtered out with mntent-based
implementation.

This is intended only for stable branches to prevent current issues.

https://gitlab.gnome.org/GNOME/glib/issues/1271
2018-10-17 14:29:45 +02:00
Simon McVittie
d757bd84d1 Meson: Extract objects from convenience libraries to link them
This avoids the convenience library being treated as though it was
an installed static library (objects not included in the dependent
static library, and convenience library being listed in the pkg-config
metadata), both of which would make static linking impossible.
This is a workaround for meson not having
https://github.com/mesonbuild/meson/pull/3939 merged yet.

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1536
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-10 13:51:07 -04:00
Xavier Claessens
067d4b47c4 Meson: appinfo tests are racy if run in parallel 2018-10-10 13:51:07 -04:00
Simon McVittie
31d2273163 Spelling: Fix spelling of "unknown"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-10 13:51:07 -04:00
Simon McVittie
ff2b5d3383 Spelling: Fix spelling of "similarly"
Detected by Debian's Lintian tool.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-10 13:51:07 -04:00
Simon McVittie
59f8519ba9 meson: Run build-time tests with --tap where supported
This makes it easier to debug test failures, by ensuring that g_debug()
and g_test_message() are printed as TAP diagnostics.

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1528
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-10 13:51:06 -04:00
Xavier Claessens
ac7534fe10 Meson: Run in TAP mode installed tests that support it 2018-10-10 13:51:06 -04:00
Simon McVittie
9cde3b2709 Remove unnecessary +x permissions
None of these files starts with a #! line, and they are not native
binary executables, so if a user attempts to execute them as a program,
Unix shells will run them as /bin/sh scripts. This is not going to end
well, since none of them are shell scripts (the gio bash completion
is for bash, which is not a lowest-common-denominator POSIX shell, and
in any case is designed to be sourced rather than executed).

Fixes: #1539
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-10 13:51:06 -04:00
Xavier Claessens
100a85300f Meson: Fix missing files when installing tests
Closes #1527
2018-10-10 13:51:06 -04:00
Philip Withnall
faaf0fb83c tests: Mark two more tests as slow
These keep on taking just longer than 30s on my local machine when run
in parallel with the rest of the tests (i.e. with `ninja test`). Testing
them individually, they do terminate correctly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-10 13:51:06 -04:00
Bernhard Walle
6e1311c977 gio: automake: Add libgmodule dependency
Otherwise I get following compile error:

 libtool: link: /home/builduser/toolchains/linux/tc/2017-12/x86-ncp-linux-gnu/bin/i686-ncp-linux-gnu-gcc -Wall -Wstrict-prototypes -Wmisleading-indentation -Wno-bad-function-cast -Werror=declaration-after-statement -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=pointer-arith -Werror=init-self -Werror=format=2 -O2 -Wall -pipe -Wformat -g -fstack-protector-strong -fPIC -fno-strict-aliasing -Wl,-z -Wl,relro -Wl,-z -Wl,now -Wl,-rpath-link=/home/builduser/workspaces/rws_trunk_linux_x86_build_shared-fips/build/3p/linux/x86/install/zlib/lib -Wl,-rpath-link=/home/builduser/workspaces/rws_trunk_linux_x86_build_shared-fips/build/3p/linux/x86/install/libffi/lib -o .libs/gio gio-tool.o gio-tool-cat.o gio-tool-copy.o gio-tool-info.o gio-tool-list.o gio-tool-mime.o gio-tool-mkdir.o gio-tool-monitor.o gio-tool-mount.o gio-tool-move.o gio-tool-open.o gio-tool-rename.o gio-tool-remove.o gio-tool-save.o gio-tool-set.o gio-tool-trash.o gio-tool-tree.o  -L/home/builduser/workspaces/rws_trunk_linux_x86_build_shared-fips/build/3p/linux/x86/install/zlib/lib -L/home/builduser/workspaces/rws_trunk_linux_x86_build_shared-fips/build/3p/linux/x86/install/libffi/lib ./.libs/libgio-2.0.so ../gobject/.libs/libgobject-2.0.so ../glib/.libs/libglib-2.0.so -Wl,-rpath -Wl,/home/builduser/workspaces/rws_trunk_linux_x86_build_shared-fips/build/3p/linux/x86/install/glib/lib
 /home/builduser/toolchains/linux/tc/2017-12/x86-ncp-linux-gnu/bin/../lib/gcc/i686-ncp-linux-gnu/6.3.0/../../../../i686-ncp-linux-gnu/bin/ld: warning: libgmodule-2.0.so.0, needed by ./.libs/libgio-2.0.so, not found (try using -rpath or -rpath-link)
 ./.libs/libgio-2.0.so: undefined reference to `g_module_error'
 ./.libs/libgio-2.0.so: undefined reference to `g_module_close'
 ./.libs/libgio-2.0.so: undefined reference to `g_module_open'
 ./.libs/libgio-2.0.so: undefined reference to `g_module_supported'
 ./.libs/libgio-2.0.so: undefined reference to `g_module_symbol'
 collect2: error: ld returned 1 exit status
 Makefile:2300: recipe for target 'gio' failed

Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
2018-10-10 13:51:06 -04:00
Руслан Ижбулатов
6e75d3cf17 test_internal_enhanced_stdio: don't use g_assert()
g_assert() can be disabled, use more specific assertion macros.
2018-10-10 13:51:06 -04:00
Руслан Ижбулатов
13c088df13 W32: extend the g-file-info test with new DOS attributes 2018-10-10 13:51:06 -04:00
Руслан Ижбулатов
a2375b8929 W32: new GFileInfo attributes
G_FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT allows mountpoints
(NTFS reparse points with IO_REPARSE_TAG_MOUNT_POINT tag) to
be told apart from symlinks (NTFS reparse points with
IO_REPARSE_TAG_SYMLINK tag), even though both are reported
by glib as "symlinks".

G_FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG allows the exact
reparse tag value to be obtained by the user. This way
even more exotic reparse points can be identified and
handled by the user (glib itself currently has no code
to work with any reparse points that are not symlinks
or mountpoints).
2018-10-10 13:51:06 -04:00
Руслан Ижбулатов
d72d141c1e Enable GIO tests on Windows
1) Remove the non-Windows-only condition for subdir('tests').
2) Add libiphlpapi, libws2_32 and libsecur32 deps, needed for W32 tests.
3) Remove the -no-undefined argument (gcc doesn't understand it,
   it *does* understand -Wl,-no-undefined; either way, the test
   compiles without this argument just fine; maybe meson adds it
   by itself - you can hardly build shared modules without it).
4) Add or fix a number of includes
5) Disable gdbus-objectmanager tests when building with MSVC
   (right now these tests don't work on Windows anyway, so the fact
    that MSVC can't even build them properly is irrelevant;
    most likely gdbus-codegen needs changes to put _GLIB_EXTERN
    before each function)
2018-10-10 13:51:06 -04:00
Emmanuele Bassi
2a7d4d2dcb Merge branch 'glib-2-58-309-codegen-punning' into 'glib-2-58'
codegen: Change pointer casting to remove type-punning warnings

See merge request GNOME/glib!318
2018-09-17 13:12:47 +00:00
Jehan
ad26f4c75d Fix g_icon_to_string() regression (doc inconsistency).
g_icon_new_for_string() docs states that it should return a single name
when created with a single name. I add a second condition to this case:
the themed icon must not include default fallbacks (i.e. it must not
have been created with `g_themed_icon_new_with_default_fallbacks()`).
Otherwise the return value of `g_icon_new_for_string()` would not
recreate the same icon list when passed to `g_icon_new_for_string()`
(which would be another documentation inconsistency).

g_icon_new_for_string() is now back to old behavior for this specific
case.

I also revert the unit test for this case, and add a new unit test when
using g_themed_icon_new_with_default_fallbacks() with a single name as
well.

Closes #1513.
2018-09-17 11:33:55 +01:00
Iain Lane
d89e862f3c Merge branch 'glib-2-58-317-xdg-desktop-portal-autostart' into 'glib-2-58'
Backport “Autostart xdg-desktop-portal if needed” to glib-2-58

See merge request GNOME/glib!321
2018-09-13 14:19:24 +00:00
Iain Lane
7e413f810c gnetworkmonitornetlink: Close the socket after disconnecting its GSources
`read_netlink_messages()` is the callback attached to the netlink socket
(G_IO_IN). It calls `g_socket_receive_message()`. There is a race
condition that if the socket is closed while there is a pending call, we
will try to receive on a closed socket, which fails.

To avoid this, we switch the order of the operations around: first
destroy the source and then close the socket.
2018-09-13 14:10:39 +01:00
Iain Lane
8b26ad22d4 gnetworkmonitornetlink: Don't check if a passed-in GError ** is NULL
This is not a correct way to check if `g_socket_new_from_fd()` failed.
Instead just see if it returned `NULL` itself.

This was preventing the netlink monitor from being initialised.

Closes #1518
2018-09-13 14:10:39 +01:00
Michael Catanzaro
ce2e543c09 Autostart xdg-desktop-portal if needed
This is a speculative fix for epiphany#533, which we think might be
caused by xdg-desktop-portal not ever being started. This service is
started on-demand, not automatically.
2018-09-13 10:07:11 +01:00
Robert Ancell
b3bad4a179 codegen: Change pointer casting to remove type-punning warnings
The existing code was generating code with undefined results that modern compilers warn about:

accounts-generated.c:204:23: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     (GDBusArgInfo **) &_accounts_accounts_method_info_list_cached_users_OUT_ARG_pointers,
2018-09-12 23:34:43 +01:00
Florian Müllner
a8babc792f portal network monitor: Always emit changed signal on changed
The ::network-changed signal is documented to indicate any change in
network configuration, which doesn't necessarily imply a property
change - additional services becoming available after connecting to
a VPN comes to mind for instance.

In order to match the "native" network monitor's behavior, always
emit the signal when it's in response to the 'changed' D-Bus signal.

Also emit the signal unconditionally when loading the initial property
values, to allow clients to differentiate between "offline" meaning
"offline" and "offline" meaning "uninitialized".
2018-09-03 13:14:47 +01:00
Ryan Schmidt
afbda14f2c gio: Don't redefine GKqueueFileMonitor
Fixes build on old compilers that don't allow type redefinitions.

Closes: https://gitlab.gnome.org/GNOME/glib/issues/1506
2018-09-03 12:49:16 +01:00
Philip Withnall
d9b331f4d4 Revert "Add a gnet utility"
This reverts commit 3c1902fcf9ff9d0fb162d6ea71ec94c253687f84.

This was accidentally re-added from an old version of the branch before
!265 was merged. It should not have been re-added.
2018-08-28 11:59:04 +01:00
Philip Withnall
f65e8eb7e3 Merge branch 'subprocess-cancellable-callback-fix' into 'master'
subprocess: Fix communicate_cancelled signature

See merge request GNOME/glib!266
2018-08-28 10:32:07 +00:00
Matthias Clasen
917dee45b2 Merge branch 'network-monitor-again' into 'master'
Network monitor again

See merge request GNOME/glib!265
2018-08-27 15:32:51 +00:00
Marco Trevisan (Treviño)
72bf795db5 tests, subprocess: units for cancelled communications 2018-08-27 17:08:47 +02:00
Florian Müllner
d047ca341b portal network monitor: Validate connectivity
Only accept connectivity values that are actually
in the range of GNetworkConnectivity.

https://gitlab.gnome.org/GNOME/glib/merge_requests/227
2018-08-27 10:56:02 -04:00
Matthias Clasen
860735f01b portal network monitor: Drop the version property
Rearrange the code so we try version 3 first,
falling back to version 2 and then version 1.

We still do a construct-time check to ensure
that we work with unsupported versions.

Note that this also takes care of setting the
initial property values in the version 1 case.
2018-08-27 10:55:53 -04:00