Commit Graph

19148 Commits

Author SHA1 Message Date
Ondrej Holy
39afe07e27 Merge branch 'wip/oholy/bind-mounts' into 'master'
gunixmounts: Mark mounts as system internal instead of filtering out

See merge request GNOME/glib!366
2018-10-23 07:32:32 +00:00
Ondrej Holy
983a95c9dc gunixmounts: Mark mounts as system internal instead of filtering out
mntent-based implementation filter out mounts with device path that was
repeated. Consequently, it is not possible to show such mounts in UI even
with x-gvfs-show, because they are not returned from g_unix_mounts_get.
libmount-based implementation currently doesn't filter out any mounts
which causes issues to our volume monitors. Let's rather mark mounts
which don't point into fs root as system_internal. This approach won't be
affected by mount order as is mntent-based implementation. It will mark
more mounts as system_internal than it is filtered out with mntend-based
implementation, but there will be always possibility to show them in UI
over x-gvfs-show, which was not possible with mntend-based. We can
probably introduce some improvements later to not mark unique mounts as
system internal even if they don't point into fs root...

https://gitlab.gnome.org/GNOME/glib/issues/1271
2018-10-23 09:01:04 +02:00
Ondrej Holy
e1fa5ffb91 gio: Add g_unix_mount_get_root_path
Currently, there isn't API to determine root path for mounts created
over bind operation (or btrfs subvolumes). This causes issues to our
volume monitors if there is multiple mounts for one device, which can
happen with libmount-based implementation currently. Let's propagate
root path from libmount over g_unix_mount_get_root_path, so we can
handle this somehow in our volume monitors.

https://gitlab.gnome.org/GNOME/glib/issues/1271
2018-10-23 09:01:04 +02:00
Ondrej Holy
85de7749c4 Merge branch 'dirname-of-root-docs' into 'master'
gfileutils: Add examples to g_path_get_dirname() documentation

See merge request GNOME/glib!410
2018-10-23 06:49:57 +00:00
Philip Withnall
d192a078c8 Merge branch 'ossfuzz-9810-9825-10319-9803-9857-9801-fixes' into 'master'
Various GVariant, GMarkup and GDBus fuzzing fixes

See merge request GNOME/glib!411
2018-10-23 04:30:21 +00:00
Philip Withnall
1c421b0158 glib: Port various callers to use g_utf8_validate_len()
These were callers which explicitly specified the string length to
g_utf8_validate(), when it couldn’t be negative, and hence should be
able to unconditionally benefit from the increased string handling
length.

At least one call site would have previously silently changed behaviour
if called with strings longer than G_MAXSSIZE in length.

Another call site was passing strlen(string) to g_utf8_validate(), which
seems pointless: just pass -1 instead, and let g_utf8_validate()
calculate the string length. Its behaviour on embedded nul bytes
wouldn’t change, as strlen() stops at the first one.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
7a4025cac1 gutf8: Add a g_utf8_validate_len() function
This is a variant of g_utf8_validate() which requires the length to be
specified, thereby allowing string lengths up to G_MAXSIZE rather than
just G_MAXSSIZE.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
8e60b3dde0 tests: Use g_assert_null() in gdbus-serialization test
This introduces no real functional changes (except when compiling with
G_DISABLE_ASSERT, in which case it fixes the test). Mostly just a code
cleanup.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
c2c9c7fa3b tests: Tidy up GError handling in gdbus-serialization test
This introduces no functional changes; just a bit of code tidying.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
5f3b393662 gvariant: Clarify internal documentation about GVariant type strings
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
e03d5a335b 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-10-23 17:01:51 +13:00
Philip Withnall
968f1c6cad gdbusmessage: Fix a typo in a documentation comment
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
50b544e2c0 gdbusmessage: Clarify error returns for g_dbus_message_new_from_blob()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
94a9ab3c03 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-10-23 17:01:51 +13:00
Philip Withnall
af712bbce1 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-10-23 17:01:51 +13:00
Philip Withnall
f148687b02 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-10-23 17:01:51 +13:00
Philip Withnall
7eedcd76f7 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-10-23 17:01:51 +13:00
Philip Withnall
5e0b12df1a 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-10-23 17:01:51 +13:00
Philip Withnall
7c4e6e9fbe 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-10-23 17:01:51 +13:00
Philip Withnall
eb7c9adc3b 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-10-23 17:01:51 +13:00
Philip Withnall
ec5d6ab63d gfileutils: Add examples to g_path_get_dirname() documentation
See https://gitlab.gnome.org/GNOME/glib/merge_requests/326.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 14:38:13 +13:00
Philip Withnall
da512adc34 Merge branch 'stap-pass-cflags' into 'master'
build-sys: Pass CFLAGS to $(DTRACE)

See merge request GNOME/glib!403
2018-10-22 22:39:59 +00:00
Xavier Claessens
85e2a7d1b7 Merge branch 'ci-msys2-fix-lcovrc-path' into 'master'
ci/msys2: fix path to the lcov config file

See merge request GNOME/glib!405
2018-10-19 14:53:21 +00:00
Xavier Claessens
f745beb973 Merge branch '1542-gdbus-peer' into 'master'
Meson: Fix linking of gdbus-peer test

Closes #1542

See merge request GNOME/glib!350
2018-10-19 14:24:43 +00:00
Xavier Claessens
a46f88ba1b Meson: Fix linking of gdbus-peer test 2018-10-19 10:08:00 -04:00
Xavier Claessens
5c22b2ddde Merge branch '1bit-emufutex-slow' into 'master'
meson: Mark 1bit-emufutex test as slow

See merge request GNOME/glib!406
2018-10-19 13:35:39 +00:00
Simon McVittie
442b54f00c meson: Mark 1bit-emufutex test as slow
Emulated futexes are slower than real ones; if they were not, there
would be no point in using the real futexes. On some machines they
are sufficiently slow to cause test timeouts.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-19 09:20:25 +01:00
Simon McVittie
da83b44cce Merge branch 'master' into 'master'
grefcount: add missing gatomic.h

See merge request GNOME/glib!400
2018-10-18 19:27:11 +00:00
Michael Catanzaro
4e94164a72 Fix a couple typos in doc comments 2018-10-17 13:23:36 -05:00
Christoph Reiter
bf032e3e04 ci/msys2: fix path to the lcov config file
It was using a relative path to the source directory but we run lcov
in the build directory.
2018-10-17 18:12:40 +02:00
Colin Walters
d7233ef81e 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-15 21:50:31 +00:00
Fabrice Fontaine
09c149453a 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-13 23:10:33 +02:00
Hans Petter Jansson
035975da09 Merge branch 'master' into 'master'
ghash: Fix out-of-range use of signed integer

Closes #1570

See merge request GNOME/glib!399
2018-10-12 20:20:59 +00:00
Hans Petter Jansson
d3074a748f ghash: Fix out-of-range use of signed integer
We were mistakenly shifting a signed int literal by up to 31 places.
Specify unsigned int instead.

Closes #1570
2018-10-12 13:09:39 +02:00
Philip Withnall
603fb5958d Merge branch 'glib' into 'master'
Add useful links to fuzzing README

See merge request GNOME/glib!398
2018-10-11 21:56:15 +00:00
pdknsk
8b151f5055 Add useful links to fuzzing README 2018-10-11 22:11:00 +02:00
Emmanuele Bassi
3b5e5b8f9e Merge branch 'm4-fixes' into 'master'
m4: Fix AM_PATH_GLIB_2_0 macro

See merge request GNOME/glib!396
2018-10-11 13:04:10 +00:00
Simon McVittie
54cbc9bccf 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 12:50:21 +01:00
Philip Withnall
7ec354d1d6 Merge branch 'glib' into 'master'
Integrate oss-fuzz targets

Closes #1471

See merge request GNOME/glib!371
2018-10-11 00:02:03 +00:00
pdknsk
a2c09f57f6 Integrate oss-fuzz targets 2018-10-11 00:02:03 +00:00
Philip Withnall
6c8b9f31b1 Merge branch '179-object-unref-warning' into 'master'
gobject: Convert a debug check from an assertion to a g_critical()

Closes #179

See merge request GNOME/glib!389
2018-10-10 23:36:20 +00:00
Philip Withnall
efda2be302 Merge branch 'ghash-hpj-2018' into 'master'
GHashTable improvements

See merge request GNOME/glib!208
2018-10-10 23:01:51 +00:00
Philip Withnall
0b45ddc556 Merge branch 'poolname' into 'master'
gthreadpool: Include prgname in thread name

See merge request GNOME/glib!374
2018-10-10 22:45:08 +00:00
Philip Withnall
b9a8c03915 gobject: Convert a debug check from an assertion to a g_critical()
An assertion is harder to skip over, and using a g_critical() can give
us a more informative error message.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/179
2018-10-11 11:40:12 +13:00
Vincent Whitchurch
c50bdf07e8 gthreadpool: Include prgname in thread name
All pool threads are named "pool" and this a bit annoying when looking
at system-wide traces or statistics for a system where several
applications use thread pools.  Include the prgname in the thread names
to get a better default name.  The total length including the "pool-"
prefix is limited to 16 bytes in order for it to work on all systems.

Change-Id: I473a9f534c4630f3e81da72ff96d8f593c60efac
2018-10-10 10:57:39 +02:00
Philip Withnall
d3928abe45 Merge branch 'wip/lantw/enable-freebsd-ci-only-in-gnome' into 'master'
ci: Enable FreeBSD CI in the official repository

See merge request GNOME/glib!387
2018-10-09 21:08:54 +00:00
Ting-Wei Lan
fb8d95467d ci: Enable FreeBSD CI in the official repository
Since we are unable to promote our FreeBSD runner to a shared runner,
we can only enable it in GNOME group. This should avoid problems when
submitting merge requests from forks.
2018-10-09 23:06:06 +08:00
Emmanuele Bassi
fb65dda651 Merge branch '734-proxy-construction-docs' into 'master'
gdbusproxy: Document blocking guarantees of constructors

Closes #734

See merge request GNOME/glib!380
2018-10-09 10:20:33 +00:00
Philip Withnall
3b10fc035d Merge branch 'm4macros' into 'master'
m4macros: Allow information from pkg-config to be overridden

See merge request GNOME/glib!375
2018-10-08 22:43:46 +00:00
Philip Withnall
2eaeefdf5d gdbusproxy: Document blocking guarantees of constructors
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/734
2018-10-09 09:15:43 +13:00