Commit Graph

17215 Commits

Author SHA1 Message Date
Lars Uebernickel
0751ccd315 gdbus: fix use-after-free
g_dbus_connection_call_internal() accesses the user data it passes to
g_dbus_connection_send_message_with_reply() after the call. That data
might be freed already in the case that the callback is called
immediately.

Fix this by removing the 'serial' field from the user data altogether
and fetch the serial from the message in the callback.

https://bugzilla.gnome.org/show_bug.cgi?id=748263
2017-05-12 14:43:22 -04:00
Mario Blättermann
783e12e86c Update German translation 2017-05-12 15:23:12 +00:00
Daniel Boles
8a12fb47ce array-test: Fix a comment 2017-05-12 10:05:56 +01:00
Krzesimir Nowak
e8222c3343 gstrfuncs: Fix translation issues
The tool that extracts the translatable strings to .po files does not
cope with the G_GUINTX_FORMAT macros, so we preformat the numbers to
strings and use the strings in the translatable error messages.
2017-05-10 16:11:02 +02:00
Piotr Drąg
6b19907a4f Update POTFILES.in 2017-05-10 13:35:11 +02:00
Krzesimir Nowak
b89fed057c docs: Fix typos
Something I spotted by accident with git log.
2017-05-10 12:44:59 +02:00
Krzesimir Nowak
ce7e02193b docs: Add index for 2.54 api 2017-05-10 12:04:04 +02:00
Krzesimir Nowak
4fe89b0437 gstrfuncs: Add replacement for string-to-number functions
Very often when we want to convert a string to number, we assume that
the string contains only a number. We have g_ascii_strto* family of
functions to do the conversion but they are awkward to use - one has
to check if errno is zero, end_ptr is not NULL and *end_ptr points to
the terminating nul and then do the bounds checking. Many projects
need this kind of functionality, so it gets reimplemented all the
time.

This commit adds some replacement functions that convert a string to a
signed or unsigned number that also follows the usual way of error
reporting - returning FALSE on failure and filling an error output
parameter.
2017-05-10 12:04:03 +02:00
Chun-wei Fan
58ecc57ca7 win32/replace.py: Fix replacing items in files with UTF-8 content
Some files that this script will process might have UTF-8 items in
there, which can cause problems on Python 3.x as it is more strict and
careful on unicode issues.  Fix this by:

-Doing what we did before on Python 2.x
-Open the file with encoding='utf-8' on Python 3.x
2017-05-09 18:20:42 -07:00
Sebastian Dröge
0d81bb4e31 gmodule – Don't use RTLD_DEFAULT on Android for g_module_self() on Android 64 bit
On 64 bit Android this is #defined to 0, which is considered an invalid
library handle in all other cases. RTLD_DEFAULT is only supposed to be
used with dlsym() it seems, and the usage here was just an
"optimization" before.

By dlopen'ing NULL, we get the same on all 64 bit Android variants and it
actually works instead of erroring out. On 32 bit Android, dlopen() of
NULL unfortunately usually gives us something useless that finds no
symbols whatsoever.

https://bugzilla.gnome.org/show_bug.cgi?id=776876
2017-05-09 15:58:15 +02:00
Sebastian Dröge
cc5e9f2362 gmodule – Check for RTLD_LAZY and others in configure
They are no #defines on Android but enum values, and on 64 bit Android
they have different values than what we would otherwise fall-back to.

https://bugzilla.gnome.org/show_bug.cgi?id=776876
2017-05-09 15:58:15 +02:00
Ondrej Holy
83c1b881fb gunixmounts: Prevent unwanted automount requests
mnt_table_is_fs_mounted causes unwanted automount requests due to
canonicalization of source and target. It might be replaced by
mnt_table_find_source as per the documentation in order to prevent
the automounts, but it is redundant. All mtab entries should be already
mounted and thus mnt_table_is_fs_mounted result is always true (it
basically checks that the fs from mtab is in mtab). Let's remove
the check at all.

https://bugzilla.gnome.org/show_bug.cgi?id=781867
2017-05-09 14:28:48 +02:00
Ondrej Holy
53ed1804e2 gunixmounts: Speed up mtab processing with libmount
libmnt_context is useless. It contains cache which is useful for searching,
but it isn't used in our case. Let's use mnt_context_parse_mtab instead
directly and the mtab processing will be faster.

https://bugzilla.gnome.org/show_bug.cgi?id=781867
2017-05-09 14:28:48 +02:00
Philip Withnall
b7ffc07d98 tests: Improve error handling for fileutils test
The test_stdio_wrappers() test will spuriously fail if the mkdir-test
directory already exists and is non-empty, which can happen if a
previous test run has failed and left a coredump file in the directory.
Tighten up the error checking around the pre-test rmdir() call to catch
this failure.

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

https://bugzilla.gnome.org/show_bug.cgi?id=782237
2017-05-08 11:19:46 +01:00
Philip Withnall
5c1e85669a tests: Update g_assert()s in fileutils test to be more descriptive
Use the new g_assert_{non,}null(), g_assert_cmpint(), g_assert_true(),
etc., to get more descriptive output when the tests fail.

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

https://bugzilla.gnome.org/show_bug.cgi?id=782237
2017-05-07 20:18:30 +01:00
Philip Withnall
f9a6a9ba53 gtimer: Handle gmtime() failure in g_time_val_to_iso8601()
g_time_val_to_iso8601() has a limit to the future dates it can convert,
imposed by what gmtime() can fit in its year field. If gmtime() fails,
gracefully return NULL from g_time_val_to_iso8601() rather than trying
to dereference the NULL structure and crashing.

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

https://bugzilla.gnome.org/show_bug.cgi?id=782075
2017-05-05 11:41:37 +01:00
Philip Withnall
9374ecc3cb gdatetime: Fix overflow checks when constructing from timestamps
GDateTime does overflow checks to see if the timestamp being passed in
is too big to be represented. However, it only does those after
converting from a timestamp to an interval, which involves some
multiplications and additions — and hence can overflow, and cause the
later bounds check to erroneously succeed. This results in a non-NULL
GDateTime being returned which represents completely the wrong date.

Fix the overflow checks (do them earlier) and add some unit tests.

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

https://bugzilla.gnome.org/show_bug.cgi?id=782089
2017-05-05 10:51:08 +01:00
Rico Tzschichholz
17395d79eb Revert "ginputstream: Add missing (out) annotations to read() functions"
This reverts commit 8446ee8c20.
2017-05-04 16:27:39 +02:00
Jonh Wendell
fff6fc02b9 build: Bump version to 2.53.2
So that early adopters of new API have a version number to target.
2017-05-04 11:03:48 -03:00
Philip Withnall
b1cd3378fb gdatetime: Remove an unnecessary NULL pointer check
datetime->tz can never be NULL, so this pointer check is unnecessary and
confusing, and messes up static analysis.

https://bugzilla.gnome.org/show_bug.cgi?id=732000
2017-05-02 23:42:16 +01:00
Philip Withnall
404c2d2454 ghash: Document that GHashTable is not suitable for static hash tables
Instead, gperf should be used for that kind of thing.

Inspired by http://stackoverflow.com/q/42372382/2931197.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-05-02 16:59:50 +01:00
Philip Withnall
f6f6b3d83c garray: Add g_ptr_array_find[_with_equal_func]()
Partially based on telepathy-glib’s tp_g_ptr_array_contains(), and a
patch by Xavier Claessens <xavier.claessens@collabora.co.uk>.

Test cases included.

https://bugzilla.gnome.org/show_bug.cgi?id=698064
2017-05-02 16:54:41 +01:00
Philip Withnall
42a8e952ef gtimer: Whitespace fixes
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-05-02 16:02:30 +01:00
Krzesimir Nowak
070383ca36 gvariant: Fix the max unsigned 64-bit integer value
It should be 2^64-1, not just 2^64.

Reviewed-by: Philip Withnall <philip@tecnocode.co.uk>
2017-05-02 15:02:44 +02:00
Matthias Clasen
6ddfd516e6 Small documentation additions
The GNetworkMonitor docs were talking about one implementation,
omitting the others. While fixing that, add a bit about implementations
to the GProxyResolver docs too.
2017-05-02 07:23:32 -04:00
Matthias Clasen
f340354861 portal support: Raise the priority for network monitor
When we are inside a sandbox, we want to use the portal
implementation, since it is the only one that has a chance
of working.

This is safe to do, since the portal implementation will
just fail initialization when loaded outside a sandbox.
2017-05-02 06:48:35 -04:00
Philip Withnall
f5993c0e5d gportalsupport: Fix compilation failure from previous commit
Igor says: Thith code did not path the compilation check.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-05-01 19:34:51 +01:00
Matthias Clasen
82e31de04d portal support: Read /.flatpak-info
The flatpak-info file was moved to a different location a while
ago, we should read it from there instead of relying on the
compat symlink. One advantage is that this is a fixed, short
path, we don't have to construct one dynamically.

https://bugzilla.gnome.org/show_bug.cgi?id=781826
2017-05-01 14:15:44 -04:00
Philip Withnall
84134c64ed docs: Remove some extraneous words from g_settings_sync() documentation
Looks like the author started typing one thing, then changed their mind
about how to phrase the sentence, and typed something else.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2017-04-30 22:04:17 +01:00
Philip Withnall
d21fb0ed3c docs: Add an example for using the g_spawn_*() APIs
And clarify that you must add a child watch or *not* use the
G_SPAWN_DO_NOT_REAP_CHILD flag, otherwise your child will become a
zombie on exit, and will not be reaped until the parent process exits.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2017-04-30 09:41:35 +01:00
Timm Bäder
3e2187975d gappinfo: Clear previously set error before calling portal
Otherwise, we might end up returning TRUE from
g_app_info_launch_default_for_uri but with a set error parameter. This
will lead to confusing results depending on how the caller checks for
errors. Checking error != NULL indicats the call failed but checking the
return value indicates that it succeeded.
2017-04-29 15:15:49 +02:00
Patrick Griffis
cbcf10411c tests: Fix g_content_type_is_mime_type() test on OSX
It should be passed a mime type not a content type.

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-29 03:47:54 -04:00
Emmanuele Bassi
17a3c782db genmarshal: Always generate the prototypes in the body
This way code that does not manually include the generated marshallers
header and wishes to build with `-Wmissing-prototypes` will not generate
a compiler warning.

https://bugzilla.gnome.org/show_bug.cgi?id=781755
2017-04-28 17:39:14 +01:00
Emmanuele Bassi
616cff7c87 genmarshal: Use fewer magic numbers
https://bugzilla.gnome.org/show_bug.cgi?id=781755
2017-04-28 17:39:14 +01:00
Emmanuele Bassi
a8b5192d16 genmarshal: Constify global variables
https://bugzilla.gnome.org/show_bug.cgi?id=781755
2017-04-28 17:39:14 +01:00
Emmanuele Bassi
1ffad8fed9 genmarshal: Conform --help output to conventions
The convention for arguments taking a value is:

  --argument=VALUE

with the `VALUE` in caps.

https://bugzilla.gnome.org/show_bug.cgi?id=781755
2017-04-28 17:39:14 +01:00
declan
aefffa3fbc gdbusmessage: Don’t use major()/minor() if they’re unavailable
https://bugzilla.gnome.org/show_bug.cgi?id=777030
2017-04-28 15:26:28 +01:00
Philip Withnall
b63469d726 docs: Fix (nullable) (optional) annotations
There are a few places where commit 18a33f72 replaced valid (nullable)
(optional) annotations with just (optional). That has a different
meaning.

(nullable) (optional) can only be applied to gpointer* parameters, and
means that both the gpointer* and returned gpointer can be NULL. i.e.
The caller can pass in NULL to ignore the return value; and the returned
value can be NULL.

(optional) can be applied to anything* parameters, and means that the
anything* can be NULL. i.e. The caller can pass in NULL to ignore the
return value. The return value cannot be NULL.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-04-28 12:32:12 +01:00
Philip Withnall
88ad0dab21 gdbusconnection: Add some comments about object ownership
Some annotations I made while trying to debug bug #781847. They
introduce no behavioural changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-04-28 12:06:25 +01:00
Daniel Macks
ea586b47a3 Implement g_content_type_is_mime_type() (clone of win32's)
Add missing function, copying from gcontenttype-win32.c per Patrick
Griffis (Comment #55 of bug report)

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:30:11 -04:00
Daniel Macks
ecc27a0cba Add test-case for g_content_type_is_mime_type()
Verify presence of new interface.

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:30:11 -04:00
Rafal Luzynski
643c722f1e gosxappinfo: fix typo in g_osx_app_info_launch_internal
Correct error domain is G_IO_ERROR.

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:30:11 -04:00
Patrick Griffis
0c4dd4a802 gosxappinfo: Special case x-scheme-handler
This is the only way they are exposed on Unix so we need to handle it

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:30:11 -04:00
Patrick Griffis
fac83e09d6 gosxappinfo: Fix get_default_for_type() on 10.10+
https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:30:11 -04:00
Patrick Griffis
d4bfee1e7a build: Don't build dbus-appinfo on OSX
https://bugzilla.gnome.org/show_bug.cgi?id=780309
2017-04-27 21:52:04 -04:00
Krzesimir Nowak
75cd848ea8 gvariant: Fix some typos in documentation
Reformatted the docs for G_VARIANT_TYPE_UINT64 to avoid having a
number in the beginning of the line, because apparently gtk-doc treats
that as a first element of the numbered list. The number being that
big probably makes gtk-doc to treat it as 1.

Fixed the g_variant_new_fixed_array documentation - it was partially
copy-pasted from the g_variant_get_fixed_array documentation.

The rest should be quite obvious.

https://bugzilla.gnome.org/show_bug.cgi?id=781830
2017-04-27 15:44:08 +01:00
Patrick Griffis
f3321da462 gosxappinfo: Fix typo in ifdef
https://bugzilla.gnome.org/show_bug.cgi?id=780300
2017-04-27 09:35:29 -04:00
Daniel Mustieles
42c4a72e29 Update Spanish translation 2017-04-26 08:16:54 +00:00
Matthias Clasen
7651ce2ee4 2.53.1 2017-04-25 06:10:22 -04:00
Philip Withnall
281e301036 gmain: Allow GSource methods to be called from a finalize() callback
Temporarily increase the ref count of a GSource to 1 while calling its
finalize() callback, so that the finalize() implementation can call
GSource methods (like g_source_set_ready_time()) without causing
critical warnings. It’s safe to call those methods at this point, as the
source has been destroyed, but nothing has been freed.

This is an indirect way of fixing a race between GCancellable and
GCancellableSource, whereby the GCancellable::cancelled callback for the
GCancellableSource is not disconnected until the GCancellableSource’s
finalize() function is called. Previously, this meant there was a window
in which the GCancellableSource’s ref count was 0, but the ::cancelled
callback was still connected, and could legitimately be called as a
result of another thread calling g_cancellable_cancel() on the
GCancellable. The callback calls g_source_set_ready_time() on the
GSource, and there’s no thread-safe way of checking whether the GSource
has been destroyed. Instead, we have to change GSource so its ref count
is only decremented to 0 inside the locked section in
g_source_unref_internal() *after* the finalize() function has been
called, and hence after the GCancellable::cancelled callback has been
disconnected. The use of g_cancellable_disconnect() ensures that the
callback disconnection is thread safe.

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

https://bugzilla.gnome.org/show_bug.cgi?id=781601
2017-04-25 10:21:04 +01:00