19042 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
d8e1290b36 gvariant: Limit GVariant strings to G_MAXSSIZE
When validating a string to see if it’s valid UTF-8, we pass a gsize to
g_utf8_validate(), which only takes a gssize. For large gsize values,
this will result in the gssize actually being negative, which will
change g_utf8_validate()’s behaviour to stop at the first nul byte. That
would allow subsequent nul bytes through the string validator, against
its documented behaviour.

Add a test case.

oss-fuzz#10319

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 12:06:51 +00:00
Philip Withnall
13af758c59 gvariant: Check tuple offsets against serialised data length
As with the previous commit, when getting a child from a serialised
tuple, check its offset against the length of the serialised data of the
tuple (excluding the length of the offset table). The offset was already
checked against the length of the entire serialised tuple (including the
offset table) — but a child should not be able to start inside the
offset table.

A test is included.

oss-fuzz#9803

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 12:06:51 +00:00
Philip Withnall
d5468b90cb gvariant: Check array offsets against serialised data length
When getting a child from a serialised variable array, check its offset
against the length of the serialised data of the array (excluding the
length of the offset table). The offset was already checked against the
length of the entire serialised array (including the offset table) — but a
child should not be able to start inside the offset table.

A test is included.

oss-fuzz#9803

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 12:06:51 +00:00
Philip Withnall
e78f0a79ae gvarianttype: Impose a recursion limit of 128 on variant types
Previously, GVariant has allowed ‘arbitrary’ recursion on GVariantTypes,
but this isn’t really feasible. We have to deal with GVariants from
untrusted sources, and the nature of GVariantType means that another
level of recursion (and hence, for example, another stack frame in your
application) can be added with a single byte in a variant type signature
in the input. This gives malicious input sources far too much leverage
to cause deep stack recursion or massive memory allocations which can
DoS an application.

Limit recursion to 128 levels (which should be more than enough for
anyone™), document it and add a test. This is, handily, also the limit
of 64 applied by the D-Bus specification (§(Valid Signatures)), plus a
bit to allow wrapping of D-Bus messages in additional layers of
variants.

oss-fuzz#9857

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 12:06:51 +00:00
Philip Withnall
bfc0e49f20 gvariant: Fix checking arithmetic for tuple element ends
When checking whether a serialised GVariant tuple is in normal form,
it’s possible for `offset_ptr -= offset_size` to underflow and wrap
around, resulting in gvs_read_unaligned_le() reading memory outside the
serialised GVariant bounds.

See §(Tuples) in gvariant-serialiser.c for the documentation on how
tuples are serialised. Briefly, all variable-length elements in the
tuple have an offset to their end stored in an array of offsets at the
end of the tuple. The width of each offset is in offset_size. offset_ptr
is added to the start of the serialised tuple to get the offset which is
currently being examined. The offset array is in reverse order compared
to the tuple elements, hence the subtraction.

The bug can be triggered if a tuple contains a load of variable-length
elements, each of whose length is actually zero (i.e. empty arrays).

Includes a unit test.

oss-fuzz#9801

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
Cédric Valmary
773408d5ba Update Occitan translation 2018-11-05 18:12:03 +00:00
Simon McVittie
abc239530b Merge branch 'backport-434-arm-atomics-glib-2-58' into 'glib-2-58'
meson: Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 on GNU/Linux if needed (backport to glib-2-58)

See merge request GNOME/glib!449
2018-11-05 12:37:39 +00:00
Simon McVittie
7d72a6763c meson: Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 on GNU/Linux if needed
armv5 Linux systems implement __sync_bool_compare_and_swap() and
friends by calling a function provided by the kernel. This is not
technically an atomic intrinsic, so gcc doesn't define
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 in this case, but it's good
enough for us. Extend the current Android special case to cover
GNU/Linux too.

The possibilities are:

* __sync_foo detected and __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 predefined:
  calls to __atomic_foo or __sync_foo primitives are inlined into user
  code by gatomic.h

* __sync_foo detected but __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not
  predefined: user code has an extern reference to g_atomic_foo(),
  which calls __atomic_foo or __sync_foo because we defined
  __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 when compiling GLib itself

* Windows: user code has an extern reference to g_atomic_foo(),
  which calls InterlockedFoo()

* !defined(G_ATOMIC_LOCK_FREE): user code has an extern reference to
  g_atomic_foo(), which emulates atomic operations with a mutex

Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: #1576
2018-11-02 20:59:36 +00:00
Philip Withnall
7aa52a7d53 Merge branch '2-58-test-timeout' into 'glib-2-58'
[2.58] meson: Increase test timeouts

See merge request GNOME/glib!445
2018-11-02 10:43:52 +00:00
Simon McVittie
b1af125677 meson: Mark gdatetime test as slow
This test isn't inherently slow, but it produces so much output that
it can take a minute or more on hardware with weak I/O performance.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-01 19:09:41 +00:00
Simon McVittie
149c7504d8 meson: Increase fast test timeout from 30s to 60s
This is enough for most Debian buildds, including embedded devices
like mips and powerpcspe. It is not enough for hppa (PA-RISC), but that
architecture is so uniquely slow that it might make more sense to
special-case it downstream.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-01 19:09:41 +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
Dušan Kazik
985210849c Update Slovak translation 2018-11-01 18:05:32 +00:00
Philip Withnall
29953ccfc1 Merge branch 'backport-401-flags-validation-glib-2-58' into 'glib-2-58'
gobject/genums.c: fix flags validation (backport to glib-2-58)

See merge request GNOME/glib!439
2018-11-01 15:34:03 +00:00
Arthur Demchenkov
4d0f79e023 Add unit test for flags validation 2018-11-01 10:49:31 +00:00
Arthur Demchenkov
6f8a12ca0f gobject/genums.c: fix flags validation
gint -> glong conversion causes flags to be invalid if the highest bit
is set.

Closes #1572
2018-11-01 10:49:31 +00:00
Ondrej Holy
2daebb93fb Merge branch '326-trash-symlinks-glib-2-58' into 'glib-2-58'
glocalfile: Fix access::can-trash if parent is symlink (backport to glib-2-58)

See merge request GNOME/glib!431
2018-10-31 07:23:04 +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
Philip Withnall
fdf91511b7 Merge branch '373-month-names-glib-2-58' into 'glib-2-58'
tests: Update month name check for Lithuanian locale (backport to glib-2-58)

See merge request GNOME/glib!427
2018-10-29 23:36:46 +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
Emmanuele Bassi
bf51470ade tests: Update month name check for Lithuanian locale
Update the abbreviated month name in the test to match the GNU libc
translation, coming from CLDR.

Fixes #1562
2018-10-29 22:24:45 +00:00
Philip Withnall
1211c4503b Merge branch '2-58-339-key-file-free-fix' into 'glib-2-58'
Backport “gkeyfile: remain usable after g_key_file_free()” to glib-2-58

See merge request GNOME/glib!367
2018-10-29 22:21:04 +00:00
Fabio Tomat
aa56c0f9e9 Update Friulian translation 2018-10-27 11:04:33 +00:00
Matej Urbančič
604248b026 Updated Slovenian translation 2018-10-25 21:35:36 +02: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
Matej Urbančič
17519e039f Updated Slovenian translation 2018-10-23 16:34:02 +02: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
Fabrice Fontaine
57efb14f05 grefcount: add missing gatomic.h
Without gatomic.h, build fails on:
In file included from garcbox.c:24:0:
garcbox.c: In function ‘g_atomic_rc_box_acquire’:
grefcount.h:101:13: error: implicit declaration of function ‘g_atomic_int_get’; did you mean ‘__atomic_store’? [-Werror=implicit-function-declaration]
     (void) (g_atomic_int_get (rc) == G_MAXINT ? 0 : g_atomic_int_inc ((rc))); \
             ^
garcbox.c:292:3: note: in expansion of macro ‘g_atomic_ref_count_inc’
   g_atomic_ref_count_inc (&real_box->ref_count);

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2018-10-23 14:26:40 +13:00
Xavier Claessens
a03083ee17 Meson: Fix linking of gdbus-peer test 2018-10-19 10:34:02 -04:00
Xavier Claessens
dcc12e0311 Merge branch 'cherry-pick-5c22b2dd' into 'glib-2-58'
Merge branch '1bit-emufutex-slow' into 'master'

See merge request GNOME/glib!408
2018-10-19 14:04:34 +00:00
Xavier Claessens
4aca783bd7 Merge branch '1bit-emufutex-slow' into 'master'
meson: Mark 1bit-emufutex test as slow

See merge request GNOME/glib!406

(cherry picked from commit 5c22b2ddde21c9080d1a9a090e1945f7a1d4c5f2)

442b54f0 meson: Mark 1bit-emufutex test as slow
2018-10-19 13:37:58 +00:00
Xavier Claessens
8c6ec7615c Merge branch '1543-glib-2-58-backports' into 'glib-2-58'
Resolve "Backport recent Meson/pkg-config/test fixes to glib-2-58"

See merge request GNOME/glib!392
2018-10-19 13:37:17 +00: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
34a3ba72c9 m4macros: Fix detection of glib-2.0 alone
We unconditionally appended ">= $min_glib_version" to the modules to
look for, even though we had already included
"glib-2.0 >= $min_glib_version" in our list. When requesting additional
modules, this was fine, for example

    AM_PATH_GLIB_2_0([2.58], [:], [:], [gobject gio])

ended up asking pkg-config for

    glib-2.0 >= 2.58 gobject-2.0 gio-2.0 >= 2.58

which is redundant (since they all share a version number) but
otherwise OK.

However,

    AM_PATH_GLIB_2_0([2.58], [:], [:], [])

ended up asking pkg-config for

    glib-2.0 >= 2.58 >= 2.58

which is not OK; the second ">=" was parsed as a bizarrely-named package
to check for, and obviously few people have ">=.pc" installed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Fixes: 4bb16f48 "m4macros: Allow information from pkg-config to be overridden"
2018-10-11 10:19:52 -04:00
Simon McVittie
19c9081773 m4macros: Allow information from pkg-config to be overridden
By using PKG_CHECK_VAR, we declare $GLIB_COMPILE_SCHEMAS,
$GLIB_GENMARSHAL, $GOBJECT_QUERY, $GLIB_MKENUMS and
$GLIB_COMPILE_RESOURCES as Autoconf "precious variables" with AC_ARG_VAR,
similar to $PKG_CONFIG and $CC, so that they can be put on a configure
command line:

    ./configure GLIB_COMPILE_RESOURCES=my-glib-compile-resources

If they are set to a non-empty value, PKG_CHECK_VAR will use that
instead of auto-detecting from pkg-config, so that builders can
override them, for example when cross-compiling.

Similarly, use the standard PKG_CHECK_MODULES macro to get GLib's CFLAGS
and LIBS.

It's possible that most of the rest of each macro can also disappear,
but for the moment I've given them the benefit of the doubt.

This does result in printing "checking for GLIB" twice (once for
PKG_CHECK_MODULES and once for GLib's custom checks), but if you're
using Autotools, you probably don't have a strong objection to overly
verbose output.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-11 10:19:52 -04:00
Simon McVittie
55b17dccfc Autotools: Move libmount from Libs.private to Requires.private
libmount depends on libblkid, so if we statically link a trivial
executable to GIO, we need to pull in both libmount and libblkid.
Linking with -lmount is not enough to achieve that, but recursing
into mount.pc is.

This makes the Autotools build a bit more like the Meson build,
which already puts mount in Requires.private.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-10 20:37:49 -04:00