Commit Graph

6882 Commits

Author SHA1 Message Date
Chun-wei Fan
cf02c280ff gio/tests/pollable.c: Fix build on non-Linux UNIX
For non-Linux UNIX systems, the label 'close_libutil:' in
'test_pollable_unix_pty()' will have no statement that goes with that
label.  Just do a 'return' on non-Linux UNIX systems.
2021-02-27 10:53:53 +08:00
Sebastian Dröge
81c4f4de4d Merge branch 'gio/gfileinfo/g_file_info_get_size/documentation' into 'master'
Improving documentation for g_file_info_get_size, fixing #2333

Closes #2333

See merge request GNOME/glib!1964
2021-02-26 08:29:19 +00:00
Uwe Scholz
429ccbd6d3 Improved the description of g_file_info_get_content_type function 2021-02-25 21:46:59 +01:00
Simon McVittie
f443144091 Merge branch 'pollable-test-dlopen-leak' into 'master'
tests: Fix leak of dlopened module in pollable test

See merge request GNOME/glib!1936
2021-02-25 18:26:57 +00:00
Uwe Scholz
73182528fa Improving documentation for g_file_info_get_size, fixing #2333 2021-02-24 23:13:27 +01:00
Michael Catanzaro
26f6e3db9e gkeyfilesettingsbackend: check for errors when creating file monitors
File monitor creation may fail. We should check for this, rather than
ignoring it and then spewing criticals upon improperly assuming that we
have a valid GFileMonitor rather than NULL.

In practice, creating the GFileMonitors here fail when opening a large
number of tabs in Epiphany. I'm still investigating to see why, but it
doesn't matter for the purposes of this commit.
2021-02-23 16:31:26 -06:00
Sebastian Dröge
7b0ac98afe Merge branch '2332-subprocess-launcher-oops' into 'master'
gsubprocesslauncher: Don’t close target FDs in close() method

Closes #2332

See merge request GNOME/glib!1958
2021-02-20 10:07:03 +00:00
Philip Withnall
50cf90dc56 tests: Test g_subprocess_launcher_close() doesn’t close too many FDs
Expand an existing unit test to check that the target FD of a
`g_subprocess_launcher_take_fd()` call doesn’t get closed when
`g_subprocess_launcher_close()` is called. Only the source FD should be
closed by the parent process.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2332
2021-02-19 18:27:00 +00:00
Philip Withnall
55a75590d0 gsubprocesslauncher: Don’t close target FDs in close() method
This is a regression introduced in commit 67a589e505. Previously, the
source/target FD pairs were stored in `needdup_fd_assignments`, in
consecutive entries, so source FDs had even indices and target FDs had
odd indices.

I didn’t notice that the array index was being incremented by 2 when
closing FDs, when porting from the old code. So previously the code was
only closing the source FDs; after the port, it was closing source and
target FDs.

That’s incorrect, as the target FDs are just integers in the parent
process. It’s only in the child process where they are actually FDs —
and `g_subprocess_launcher_close()` is never called in the child
process.

This resulted in some strange misbehaviours in any process which used
`g_subprocess_launcher_take_fd()` with target FDs which could have
possibly aliased with other FDs in the parent process (and which weren’t
equal to their mapped source FDs).

Thanks to Olivier Fourdan for the detailed bug report.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2332
2021-02-19 18:27:00 +00:00
Philip Withnall
1e74c52a63 gsubprocesslauncher: Improve documentation formatting slightly
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-19 18:27:00 +00:00
Emmanuel Fleury
23dad977d8 Change SkipAsyncData fields to be gsize (and not gssize) 2021-02-19 18:10:30 +01:00
Sebastian Dröge
b41147dfc9 The ETag returned by various GFile functions is nullable
This was correctly annotated for proper return values but in case of out
parameters it was only annotated as (optional) and not additionally as
(nullable).
2021-02-17 10:01:36 +02:00
Philip Withnall
51e964849b Merge branch '2097-spawn-fd-rewriting' into 'master'
Resolve "GSubprocessLauncher with FD assignment can clash with g_spawn_async internal pipe"

Closes #2097

See merge request GNOME/glib!1690
2021-02-16 14:04:39 +00:00
Philip Withnall
67a589e505 gsubprocess: Use new source/target FD mapping functionality in g_spawn()
This improves performance by eliminating the use of a
`GSpawnChildSetupFunc` in the common case (since that setup code has now
moved into `g_spawn*()` itself), and enables the use of the fix to avoid
the child error reporting FD being overwritten by target FD mappings,
introduced via `g_spawn_async_with_pipes_and_fds()`.

It reworks how the source/target FD mapping is stored within
`GSubprocessLauncher` to match what `g_spawn*()` uses. The two
approaches are equivalent.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2097
2021-02-16 13:44:00 +00:00
Emmanuel Fleury
0dde9f3744 Fix signedness warning in gio/gmemoryoutputstream.c
gio/gmemoryoutputstream.c: In function ‘g_memory_output_stream_seek’:
gio/gmemoryoutputstream.c:792:44: error: comparison of integer expressions of different signedness: ‘goffset’ {aka ‘long int’} and ‘gsize’ {aka ‘long unsigned int’}
  792 |   if (priv->realloc_fn == NULL && absolute > priv->len)
      |                                            ^
2021-02-16 13:32:26 +01:00
Emmanuel Fleury
e939550cad Fix signedness warning in gio/gdummyfile.c
gio/gdummyfile.c: In function ‘unescape_string’:
gio/gdummyfile.c:485:32: error: comparison of integer expressions of different signedness: ‘long int’ and ‘size_t’ {aka ‘long unsigned int’}
  485 |   g_warn_if_fail (out - result <= strlen (escaped_string));
      |                                ^~
2021-02-16 13:32:26 +01:00
Emmanuel Fleury
18097c8acb Fix signedness warning in gio/gbufferedinputstream.c:g_buffered_input_stream_seek()
gio/gbufferedinputstream.c: In function ‘g_buffered_input_stream_seek’:
gio/gbufferedinputstream.c:899:18: error: comparison of integer expressions of different signedness: ‘goffset’ {aka ‘long int’} and ‘gsize’ {aka ‘long unsigned int’}
  899 |       if (offset <= priv->end - priv->pos && offset >= -priv->pos)
      |                  ^~
gio/gbufferedinputstream.c:899:53: error: comparison of integer expressions of different signedness: ‘goffset’ {aka ‘long int’} and ‘gsize’ {aka ‘long unsigned int’}
  899 |       if (offset <= priv->end - priv->pos && offset >= -priv->pos)
      |                                                     ^~
2021-02-16 13:32:26 +01:00
Emmanuel Fleury
ebb3427f22 Fix signedness warnings in gio/gapplication-tool.c
gio/gapplication-tool.c: In function ‘app_help’:
glib/gmacros.h:806:26: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘size_t’ {aka ‘long unsigned int’}
gio/gapplication-tool.c:121:26: note: in expansion of macro ‘MAX’
  121 |               maxwidth = MAX(maxwidth, strlen (_(substvars[i].var)));
      |                          ^~~
gio/gapplication-tool.c: In function ‘app_help’:
glib/gmacros.h:806:26: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘size_t’ {aka ‘long unsigned int’}
gio/gapplication-tool.c:140:20: note: in expansion of macro ‘MAX’
  140 |         maxwidth = MAX(maxwidth, strlen (topics[i].command));
      |                    ^~~
2021-02-16 13:32:26 +01:00
Emmanuel Fleury
02126e0a07 Fix missing initializer warnings in gio/gapplication-tool.c
gio/gapplication-tool.c:51:3: error: missing initializer for field ‘synopsis’ of ‘const struct help_topic’
   51 |   },
      |   ^
gio/gapplication-tool.c:54:3: error: missing initializer for field ‘synopsis’ of ‘const struct help_topic’
   54 |   },
      |   ^
2021-02-16 13:32:26 +01:00
Emmanuel Fleury
e89bd4cc15 Fix several signedness warnings in gio/gapplication-tool.c
gio/gapplication-tool.c: In function ‘app_help’:
gio/gapplication-tool.c:90:21: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
   90 |       for (i = 0; i < G_N_ELEMENTS (topics); i++)
      |                     ^
gio/gapplication-tool.c:117:25: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
  117 |           for (i = 0; i < G_N_ELEMENTS (substvars); i++)
      |                         ^
gio/gapplication-tool.c:121:25: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
  121 |           for (i = 0; i < G_N_ELEMENTS (substvars); i++)
      |                         ^
gio/gapplication-tool.c:137:21: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
  137 |       for (i = 0; i < G_N_ELEMENTS (topics); i++)
      |                     ^
gio/gapplication-tool.c:140:21: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
  140 |       for (i = 0; i < G_N_ELEMENTS (topics); i++)
      |                     ^
2021-02-16 13:32:25 +01:00
Emmanuel Fleury
80e2dc3a7a Fix signedness warning in gio/gdbus-tool.c
gio/gdbus-tool.c:1183:95: error: comparison of integer expressions of different signedness: ‘guint’ {aka ‘unsigned int’} and ‘int’
 1183 |           if ((fd_id = g_unix_fd_list_append (fd_list, g_variant_get_handle (value), &error)) == -1)
      |                                                                                               ^~
2021-02-16 13:32:25 +01:00
Philip Withnall
8323997f3f glocalfileinputstream: Drop custom skip vfunc implementation
Since the previous commit, the generic `GInputStream` implementation of
`skip()` is now equivalent, and results in the same calls to `lseek()`.

Heavily based on an approach by Dan Winship in
https://bugzilla.gnome.org/show_bug.cgi?id=681374.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #587
2021-02-15 23:10:41 +00:00
Philip Withnall
58c6e0e5d4 ginputstream: Don’t skip off the end of resizable streams
The default implementation of `g_input_stream_skip()` can skip off the
end of resizable streams, as that’s the behaviour of `g_seekable_seek()`
for that type of stream.

This has previously been fixed for local file input streams (commit
89f9615835), and a unit test added there.
However, the fix should be more generally made in `GInputStream`.

This commit reworks an old patch by Dan Winship on
https://bugzilla.gnome.org/show_bug.cgi?id=681374, which took that
approach.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #587
2021-02-15 23:10:41 +00:00
Philip Withnall
1e21abf0c4 gtestdbus: Flush stdout and stderr before forking a monitor process
This is a workaround for the fact that forking without execing is not
easy to do correctly, and `GTestDBus` doesn’t do it correctly. However,
`GTestDBus` is de-facto deprecated and so putting any more effort in is
a waste.

This fixes an issue where a test would print duplicate output when
outputting to a fully-buffered FD, such as a pipe. This is because the
buffer is non-empty before the `fork()`, and ends up duplicated in the
parent and child processes, both of which later flush the duplicated
buffer contents.

Diagnosed and fix suggested by Simon McVittie.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2322
2021-02-15 10:33:32 +00:00
Simon McVittie
ee53840fa6 tests: Use a more realistic language code than sv_SV
Swedish as spoken in El Salvador is not listed in
/usr/share/i18n/SUPPORTED, and in any case is probably not what we meant.
A more plausible language code would be Swedish as spoken in Sweden.

Prompted by improving the Debian packaging of GLib to generate most of
the language codes mentioned in the tests, so that we can have better
test coverage.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-14 14:43:12 +00:00
Philip Withnall
2f91caf77e tests: Add a basic test for require-same-user D-Bus auth flag
It’s not feasible to test that the require-same-user flag can cause
authentication to fail, as that would require the build environment to
have two users available. We can, however, test that it passes when
authenticating a client and server running under the same user account.

I have manually tested that the new flag works, by running the following
as user A:
```
`$prefix/gdbus-daemon --print-env &`
gdbus call --session --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.ListNames
```

And then running the `gdbus call` command again as user B (with the same
value for `DBUS_SESSION_BUS_ADDRESS` in the environment), which
produces:
```
Error connecting: Unexpected lack of content trying to read a line
```
(an authentication rejection)

Commenting out the use of
`G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER` from
`gdbusdaemon.c`, the `gdbus call` command succeeds for both users.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-11 16:12:40 +00:00
Philip Withnall
5d0ffe73b7 gdbusdaemon: Use require-same-user flag to avoid auth observer signal
This doesn’t change the `GDBusDaemon` behaviour, but does simplify the
code a little.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1804
2021-02-11 16:12:40 +00:00
Philip Withnall
1a6aa9a493 gdbus: Add flags to require authentication as the same user
This eliminates a common use case for the
`GDBusAuthObserver::authorize-authenticated-peer` signal, which is often
implemented incorrectly by people.

Suggested by Simon McVittie.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #1804
2021-02-11 16:12:40 +00:00
Philip Withnall
137a9bdcc2 gdbusauth: Use g_clear_object() to simplify the code a little
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-11 16:06:27 +00:00
Philip Withnall
a1db705bc2 Merge branch 'wip/gdbus-flags-from-the-future' into 'master'
gdbus: Reject attempts to set future connection or server flags

See merge request GNOME/glib!1934
2021-02-11 11:53:13 +00:00
Sebastian Dröge
90d34b3078 Merge branch 'keyfile-settings-fix-again' into 'master'
gkeyfilesettingsbackend: Fix basename handling when group is unset

See merge request GNOME/glib!1941
2021-02-11 08:00:00 +00:00
Philip Withnall
68ce7a28e1 tests: Add tests for key name handling in the keyfile backend
This tests the two recent commits.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-10 22:10:00 +00:00
Philip Withnall
a59247608f gkeyfilesettingsbackend: Disallow empty key or group names
These should never have been allowed; they will result in precondition
failures from the `GKeyFile` later on in the code.

A test will be added for this shortly.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-10 21:20:11 +00:00
Philip Withnall
9d27c57f70 gkeyfilesettingsbackend: Fix basename handling when group is unset
Fix an effective regression in commit
7781a9cbd2, which happens when
`convert_path()` is called with a `key` which contains no slashes. In
that case, the `key` is entirely the `basename`.

Prior to commit 7781a9cb, the code worked through a fluke of `i == -1`
cancelling out with the various additions in the `g_memdup()` call, and
effectively resulting in `g_strdup (key)`.

Spotted by Guido Berhoerster.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-10 21:16:39 +00:00
Emmanuel Fleury
bdcd7eca3b Fix missing initializer warning in gio/glib-compile-resources.c
gio/glib-compile-resources.c: In function ‘parse_resource_file’:
gio/glib-compile-resources.c:553:3: error: missing initializer for field ‘passthrough’ of ‘GMarkupParser’ {aka ‘struct _GMarkupParser’}
  553 |   GMarkupParser parser = { start_element, end_element, text };
      |   ^~~~~~~~~~~~~
2021-02-10 20:44:21 +01:00
Emmanuel Fleury
7c7aec9b31 Fix several signedness warnings in gio/gio-tool-tree.c
gio/gio-tool-tree.c: In function ‘do_tree’:
gio/gio-tool-tree.c:124:22: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’
  124 |        for (n = 0; n < level; n++)
      |                      ^
gio/gio-tool-tree.c:197:21: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’
  197 |       for (n = 0; n < level; n++)
      |                     ^
2021-02-10 20:43:58 +01:00
Emmanuel Fleury
a54ebd6860 Fix missing initializer warning in gio/gio-tool-monitor.c
gio/gio-tool-monitor.c:48:3: error: missing initializer for field ‘description’ of ‘GOptionEntry’ {aka ‘const struct _GOptionEntry’}
   48 |   { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &watch_default },
      |   ^
2021-02-10 20:41:16 +01:00
Emmanuel Fleury
85f2492111 Fix signedness warning in gio/gio-tool.c:attribute_flags_to_string()
gio/gio-tool.c: In function ‘attribute_flags_to_string’:
gio/gio-tool.c:171:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’
  171 |   for (i = 0; i < G_N_ELEMENTS (flag_descr); i++)
      |                 ^
2021-02-10 20:41:16 +01:00
Emmanuel Fleury
6b3e39fafd Fix several missing initializer warnings in gio/glib-compile-schemas.c
gio/glib-compile-schemas.c: In function ‘parse_gschema_files’:
gio/glib-compile-schemas.c:1773:3: error: missing initializer for field ‘passthrough’ of ‘GMarkupParser’ {aka ‘struct _GMarkupParser’}
 1773 |   GMarkupParser parser = { start_element, end_element, text };
      |   ^~~~~~~~~~~~~
gio/glib-compile-schemas.c: In function ‘main’:
gio/glib-compile-schemas.c:2176:5: error: missing initializer for field ‘arg_description’ of ‘GOptionEntry’ {aka ‘struct _GOptionEntry’}
 2176 |     { "allow-any-name", 0, 0, G_OPTION_ARG_NONE, &allow_any_name, N_("Do not enforce key name restrictions") },
      |     ^
2021-02-10 20:41:16 +01:00
Emmanuel Fleury
93f3831ed3 Fix several signedness warnings in gio/glib-compile-schemas.c
gio/glib-compile-schemas.c: In function ‘key_state_set_range’:
gio/glib-compile-schemas.c:376:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
  376 |   for (i = 0; i < G_N_ELEMENTS (table); i++)
      |                 ^
gio/glib-compile-schemas.c: In function ‘key_state_serialise’:
gio/glib-compile-schemas.c:714:29: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
  714 |               for (i = 0; i < size / sizeof (guint32); i++)
      |                             ^
2021-02-10 20:41:16 +01:00
Emmanuel Fleury
8b1959dafe Fix several signedness warnings in gio/gsettings-mapping.c
gio/gsettings-mapping.c: In function ‘g_settings_set_mapping_int’:
gio/gsettings-mapping.c:65:23: error: comparison of integer expressions of different signedness: ‘gint64’ {aka ‘long int’} and ‘long unsigned int’
   65 |       if (0 <= l && l <= G_MAXUINT64)
      |                       ^~
gio/gsettings-mapping.c: In function ‘g_settings_set_mapping_float’:
gio/gsettings-mapping.c:120:23: error: comparison of integer expressions of different signedness: ‘gint64’ {aka ‘long int’} and ‘long unsigned int’
  120 |       if (0 <= l && l <= G_MAXUINT64)
      |                       ^~
gio/gsettings-mapping.c: In function ‘g_settings_get_mapping_int’:
gio/gsettings-mapping.c:224:27: error: comparison of integer expressions of different signedness: ‘gint64’ {aka ‘long int’} and ‘long unsigned int’
  224 |       return (0 <= l && l <= G_MAXUINT64);
      |                           ^~
gio/gsettings-mapping.c: In function ‘g_settings_get_mapping_float’:
gio/gsettings-mapping.c:269:27: error: comparison of integer expressions of different signedness: ‘gint64’ {aka ‘long int’} and ‘long unsigned int’
  269 |       return (0 <= l && l <= G_MAXUINT64);
      |                           ^~
2021-02-10 20:41:16 +01:00
Emmanuel Fleury
a5e3be4a0c Adding a missing test on integer overflow within g_http_proxy_connect()
Fixes #2315
2021-02-09 18:07:20 +00:00
Philip Withnall
3e5e7aa8e9 Merge branch 'master' into 'master'
Add support for Tilix and Konsole

See merge request GNOME/glib!1923
2021-02-09 11:09:59 +00:00
Philip Withnall
57a5ed3d08 tests: Fix leak of dlopened module in pollable test
Coverity CID: #1446243

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-09 11:06:53 +00:00
Philip Withnall
652026b9d1 Merge branch 'fix_more_warnings' into 'master'
Fix more warnings

See merge request GNOME/glib!1918
2021-02-09 10:45:51 +00:00
Simon McVittie
ba25c8a770 gdbus: Reject attempts to set future connection or server flags
The GDBusConnectionFlags and GDBusServerFlags can affect how we carry
out authentication and authorization, either making it more or less
restrictive, so it's desirable to "fail closed" if a program is compiled
against a new version of GLib but run against an old version.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-08 13:35:16 +00:00
Simon McVittie
df4501316c tls-interaction: Add test coverage for various ways to set the password
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-08 10:22:48 +00:00
Simon McVittie
61bb52ec42 gtlspassword: Fix inverted assertion
The intention here was to assert that the length of the password fits
in a gssize. Passwords more than half the size of virtual memory are
probably excessive.

Fixes: a8b204ff "gtlspassword: Forbid very long TLS passwords"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-08 10:05:15 +00:00
Emmanuel Fleury
05c311a961 Fix several missing initializer in gio/gsettingsschema.c:parse_into_text_tables()
gio/gsettingsschema.c: In function ‘parse_into_text_tables’:
gio/gsettingsschema.c:682:3: error: missing initializer for field ‘passthrough’ of ‘GMarkupParser’ {aka ‘struct _GMarkupParser’}
  682 |   GMarkupParser parser = { start_element, end_element, text };
      |   ^~~~~~~~~~~~~
gio/gsettingsschema.c:683:3: error: missing initializer for field ‘gettext_domain’ of ‘TextTableParseInfo’ [-Werror=missing-field-initializers]
  683 |   TextTableParseInfo info = { summaries, descriptions };
      |   ^~~~~~~~~~~~~~~~~~
2021-02-08 11:00:33 +01:00
Emmanuel Fleury
7c32b1173a Fix signedness warning in gio/gmenu.c:g_menu_remove()
gio/gmenu.c: In function ‘g_menu_remove’:
gio/gmenu.c:483:47: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  483 |   g_return_if_fail (0 <= position && position < menu->items->len);
      |                                               ^
2021-02-08 11:00:33 +01:00