18104 Commits

Author SHA1 Message Date
Philip Withnall
b78fb7407a 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-11-06 12:07:47 +00:00
Philip Withnall
244da15037 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-11-06 12:07:47 +00:00
Philip Withnall
2eded09ba3 gvariant: Clarify internal documentation about GVariant type strings
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 12:07:47 +00:00
Philip Withnall
8a83d15564 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:07:47 +00:00
Philip Withnall
d993f42700 gdbusmessage: Fix a typo in a documentation comment
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 12:07:47 +00:00
Philip Withnall
c387ab9c9d gdbusmessage: Clarify error returns for g_dbus_message_new_from_blob()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 12:07:47 +00:00
Philip Withnall
20e8040a76 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:07:47 +00:00
Philip Withnall
a770239d71 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:07:47 +00:00
Philip Withnall
355c4b4176 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:07:47 +00:00
Philip Withnall
6cc2994dfb 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:07:47 +00:00
Philip Withnall
fe9564feda 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:07:47 +00:00
Philip Withnall
a95e9f79d8 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:07:47 +00:00
Philip Withnall
22350edcd6 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-02 16:07:09 +00:00
Philip Withnall
7ac9adbe1e ci: Update CI image to use 2-58:v1 from registry
The CI image which this glib-2-56 branch was previously using has been
deleted from the registry (master has moved on). Tweak the CI
configuration to use the glib-2-58 image, since there doesn’t seem to be
much point in adding an image just for glib-2-56, given how little
development is still needed on this branch.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-02 16:07:09 +00:00
Aurimas Černius
25f32b3352 Updated Lithuanian translation 2018-10-07 16:37:24 +03:00
Philip Withnall
c5b577fbf5 2.56.3
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2.56.3
2018-09-21 10:41:56 +01:00
Matej Urbančič
e8756552e9 Updated Slovenian translation 2018-09-17 21:16:43 +02:00
Kukuh Syafaat
6f49a2f2af Update Indonesian translation 2018-09-14 13:06:07 +00:00
Balázs Úr
3fb0950701 Update Hungarian translation 2018-09-13 22:01:06 +00:00
Iain Lane
1516e47181 Merge branch 'glib-2-56-313-network-monitor-netlink-fixes' into 'glib-2-56'
Backport GNetworkMonitorNetlink fixes from !313 to glib-2-56

See merge request GNOME/glib!325
2018-09-13 14:14:50 +00:00
Iain Lane
38482ead59 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:11:30 +01:00
Iain Lane
2cc2663434 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:11:30 +01:00
Marek Cernocky
96e8e03a57 Updated Czech translation 2018-09-13 13:59:24 +02:00
Rafael Fontenelle
27d3e353ce Update Brazilian Portuguese translation 2018-09-08 02:10:33 +00:00
Anders Jonsson
084282328d Update Swedish translation 2018-09-07 20:59:27 +00:00
Tim Sabsch
a1dfad90d1 Update German translation 2018-09-07 17:57:15 +00:00
Piotr Drąg
6bcc1e4bcb Update Polish translation 2018-09-07 19:04:23 +02:00
Philip Withnall
d188851253 Merge branch 'markup-cve-fixes-2-56' into 'glib-2-56'
Backport gmarkup fixes to 2.56

See merge request GNOME/glib!307
2018-09-07 11:34:19 +00:00
Philip Withnall
c008d2c436 gmarkup: Fix crash in error handling path for closing elements
If something which looks like a closing tag is left unfinished, but
isn’t paired to an opening tag in the document, the error handling code
would do a null pointer dereference. Avoid that, at the cost of
introducing a new translatable error message.

Includes a test case, courtesy of pdknsk.

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

https://gitlab.gnome.org/GNOME/glib/issues/1461
(cherry picked from commit fccef3cc822af74699cca84cd202719ae61ca3b9)
2018-09-06 17:56:21 +01:00
Philip Withnall
6ea19a71e8 gmarkup: Fix unvalidated UTF-8 read in markup parsing error paths
When formatting the error messages for markup parsing errors, the parser
was unconditionally reading a UTF-8 character from the input buffer —
but the buffer might end with a partial code sequence, resulting in
reading off the end of the buffer by up to three bytes.

Fix this and add a test case, courtesy of pdknsk.

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

https://gitlab.gnome.org/GNOME/glib/issues/1462
(cherry picked from commit cec71705406f0b2790422f0c1aa0ff3b4b464b1b)
2018-09-06 17:56:21 +01:00
Philip Withnall
5716eeacaf Merge branch '266-subprocess-communicate-glib-2-56' into 'glib-2-56'
Backport g_subprocess_communicate() cancellation fixes from !266 to glib-2-56

See merge request GNOME/glib!278
2018-08-30 12:35:13 +00:00
Marco Trevisan (Treviño)
cb63affd8d tests, subprocess: units for cancelled communications 2018-08-30 13:25:35 +01:00
Marco Trevisan (Treviño)
80a2648953 subprocess: Fix communicate_cancelled signature
The source callback for a GCancellable should have the cancellable itself
as first argument.
This was not the case, and when this code was hit, we were instead trying
to treat the pointer as a CommunicateState reference and thus wrongly
deferencing it, causing a memory error and a crash.
2018-08-30 13:25:35 +01:00
Simon McVittie
8ca9c2e350 Merge branch '1465-g-gnuc-malloc-on-glib-2-56' into 'glib-2-56'
Backport G_GNUC_MALLOC fixes from #1465 to glib-2-56

See merge request GNOME/glib!261
2018-08-23 09:21:10 +00:00
Philip Withnall
c582b947cb Merge branch 'test-ip_mreq_source-android-only-2-56' into 'glib-2-56'
build: only test for broken ip_mreq_source on Android. Fixes #1472

See merge request GNOME/glib!249
2018-08-22 16:22:43 +00:00
Christoph Reiter
966b3d80e9 build: only test for broken ip_mreq_source on Android. Fixes #1472
7efd76dd6796f8 added these configure time tests to work around a bug
with older Android. Since the test didn't take Windows into account it
wrongfully applied the workaround on Windows too, breaking the build.
With meson this wasn't an issue since the check is skipped on Windows there
and our CI didn't catch this issue.

Change the test to run on Android only for meson and autotools.
This also makes it clear that the test+code can be dropped again if we stop
supporting older Android versions at some point.
2018-08-22 18:08:46 +02:00
Philip Withnall
0e10479f85 glib: Drop G_GNUC_MALLOC usage from various other allocation functions
These functions may be OK to leave the G_GNUC_MALLOC attribute on,
because the only valid pointers in the storage areas they return are,
themselves, new pointers.

However, it’s a lot easier to remove the attributes now than to try and
diagnose miscompilations in future. The performance impact of this is
likely to be unmeasurable. If there are performance problems caused by
this, then they can be profiled and fixed case-by-case in future,
bearing in mind the possibility for miscompilation if G_GNUC_MALLOC is
readded.

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

https://gitlab.gnome.org/GNOME/glib/issues/1465
2018-08-22 14:12:18 +01:00
Philip Withnall
41f23a2c44 glib: Drop G_GNUC_MALLOC usage from various allocation functions
These are our most critically incorrect uses of G_GNUC_MALLOC. See the
previous commit for details.

(Backport to 2.56: Drop the grcbox.h changes.)

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

https://gitlab.gnome.org/GNOME/glib/issues/1465
2018-08-22 14:12:18 +01:00
Philip Withnall
3d6c8e037d docs: Update the documentation for G_GNUC_MALLOC to reflect recent GCC
Thanks to some great investigation by Benjamin Moody, it’s clear that
our documentation and usage of G_GNUC_MALLOC has fallen behind GCC’s
interpretation of the malloc attribute, meaning that recent versions of
GCC could miscompile code which uses G_GNUC_MALLOC incorrectly.

Update the documentation of G_GNUC_MALLOC to match the current GCC
documentation (for GCC 8.2). Following commits will drop our use of
G_GNUC_MALLOC from inappropriate functions.

Specifically, the change in GCC’s interpretation of the malloc attribute
which could cause miscompilation is that returned storage areas are now
assumed to not contain valid pointers — so realloc() cannot have the
malloc attribute, and neither can a function which returns a newly
allocated structure with fields initialised to other pointers.

(Backport to 2.56: Change the documentation to mention GLib 2.56.3
rather than GLib 2.58.)

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

https://gitlab.gnome.org/GNOME/glib/issues/1465
2018-08-22 14:12:02 +01:00
Emmanuele Bassi
d8a496bdb4 Merge branch 'glib-2-56-ci-failure' into 'glib-2-56'
Fix persistent CI failure on glib-2-56

See merge request GNOME/glib!259
2018-08-22 11:11:05 +00:00
Philip Withnall
1eb52b6ea1 tests: Increase timeout for network-monitor-race test
It’s consistently timing out on the CI, which makes sense since it does
333 iterations of spawning a subprocess. Give it a bit more breathing
room.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-22 11:22:02 +01:00
Matthias Clasen
d4b60396c7 2.56.2 2.56.2 2018-08-16 20:24:55 -04:00
Matthias Clasen
d0f6a59fb0 network monitor portal: update properties initially
With version 2, we need to query the values explicitly.
The properties made this automatic.
2018-08-17 00:03:32 +00:00
Matthias Clasen
7ddd1de0dd network monitor: Update portal implementation
The network monitor portal interface is changing.
Version 2 is no longer using properties, but getters
instead (this lets the portal apply access control
and avoid sending information to non-networked
sandboxes).

To support both version 1 and 2 of the interface,
we stop using generated code and instead deal with
the api differences in our own code, which is not
too difficult.

Support version 1 as well
2018-08-16 16:54:14 -04:00
Milan Crha
edcce31f8e gnetworkmonitor: Fix use-after-free when using from another thread
When using g_network_monitor_get_default() from another thread, it’s
possible for network-changed events to be processed after an instance of
GNetworkMonitor has been disposed, causing use-after-free problems.

Fix that by moving some of the initialisation into the GInitable.init()
chain, rather than in a main context idle callback.

This includes a unit test which probabilistically reproduces the bug
(but can’t do so deterministically due to it being a race condition).

Commit amended by Philip Withnall <withnall@endlessm.com> before
pushing.

https://bugzilla.gnome.org/show_bug.cgi?id=793727
2018-08-16 16:53:53 -04:00
Ondrej Holy
0b4e821763 Merge branch 'cherry-pick-volume-mount-2-56' into 'glib-2-56'
Cherry pick GVolumeMonitor mount changes to glib-2-56 from issue #1458

See merge request GNOME/glib!224
2018-08-09 14:50:51 +00:00
Philip Withnall
d338fdaf75 Merge branch '1452-backport-glib-2-56' into 'glib-2-56'
Backport GFileInfo win32 fixes to glib-2-56

See merge request GNOME/glib!237
2018-08-09 10:12:46 +00:00
Руслан Ижбулатов
7fa2ad51a8 W32: consider NTFS mounpoints to be symlinks
While mountpoints are *not* symlinks, strictly speaking,
they works in a similar enough way, so consider them to be
symlinks for the purpose of querying local file info.
2018-08-09 10:30:37 +01:00
Руслан Ижбулатов
9f56652cea W32: correctly use st_ctime
On Windows st_ctime field is the file creation time.
POSIX mandates that field to be the file state change time.
Naturally, glib code interpreted st_ctime as POSIX suggested,
and the result was bad.
Fix this by introducing special W32-only logic for setting
attributes from st_ctime field.

Fixes issue #1452.
2018-08-09 10:30:37 +01:00
Ondrej Holy
2c1aee1963 gio-tool: Hold GVolumeMonitor reference during operations
Releasing GVolumeMonitor before g_volume_mount finish cause that
g_volume_get_mount returns NULL, because the mount is not correctly
propagated to the volume.

(Backported from commit 88b8ebb5dde0512fd1e098efe4c217111876d252 with
minor merge conflicts.)

https://gitlab.gnome.org/GNOME/glib/issues/1458
2018-08-03 11:53:09 +01:00