Commit Graph

21938 Commits

Author SHA1 Message Date
Marc-André Lureau
4c6654dcd4 uri: add illegal_characters argument to unescape_bytes
It's not clear to me why this argument was excluded in the first place,
and Dan doesn't remember either. At least for consistency with
unescape_string, add it.

See also:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1574#note_867283

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-15 22:03:28 +04:00
Philip Withnall
5ca8e51ae4 Merge branch 'uri-illegal' into 'master'
uri: fix g_uri_unescape_string() regression

Closes #2160

See merge request GNOME/glib!1574
2020-07-15 15:47:06 +00:00
Marc-André Lureau
4433a46e06 uri: fix g_uri_unescape_string() regression
The illegal character set used to be applied only to the decoded
characters.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2160

Fixes: d83d68d64c ("guri: new URI parsing and generating functions")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-15 19:13:52 +04:00
Philip Withnall
1135ca25fd Merge branch 'analyzer-noreturn' into 'master'
gtestutils: Mark that g_assert_whatever() macros do not normally return

Closes #1200 and #1288

See merge request GNOME/glib!1553
2020-07-15 12:31:56 +00:00
Philip Chimento
6bdf640f51 gtestutils: Mark that g_assert_whatever() macros do not normally return
g_assert_true(), g_assert_cmpint(), and friends, can return to the
caller if test_nonfatal_assertions is set, but this is normally not the
case. In particular, for the purposes of static analysis, we
specifically don't want to assume that they might return. Clang has an
analyzer_noreturn attribute for this exact purpose, which conveniently
already has a macro in gmacros.h.

Fixes: #1288
Fixes: #1200
2020-07-15 12:45:56 +01:00
Philip Withnall
f5fc9cab96 Merge branch 'wip/wjt/2159-thread-unsafe-initialization-in-gportalsupport-c' into 'master'
portal: Read /.flatpak-info in thread-safe fashion

Closes #2159

See merge request GNOME/glib!1573
2020-07-15 11:37:12 +00:00
Will Thompson
4b3183435b portal: Read /.flatpak-info in thread-safe fashion
There is no guarantee that this function would not be called
concurrently. Particularly since flatpak_info_read was set to TRUE
before /.flatpak-info is actually read from disk, there is a potential
race where a second thread would return default values for the various
flags set from that file.

Fixes #2159
2020-07-13 16:26:44 +01:00
Jordi Mas
10f2d10f1c Update Catalan translation 2020-07-12 22:59:33 +02:00
Aurimas Černius
8b8470fea9 Updated Lithuanian translation 2020-07-12 20:30:41 +03:00
Florentina Mușat
570f27a90a Update Romanian translation 2020-07-09 09:33:06 +00:00
Yuri Chornoivan
ed70742813 Update Ukrainian translation 2020-07-09 09:23:54 +00:00
Philip Withnall
735c80dc5b Merge branch 'uri-parse-params' into 'master'
A few g_uri_parse_params() improvements

See merge request GNOME/glib!1557
2020-07-08 10:53:11 +00:00
Philip Withnall
3cabce39e8 Merge branch 'tests-limit-threads' into 'master'
tests: limit number of threads to something reasonable.

See merge request GNOME/glib!1564
2020-07-07 13:15:54 +00:00
Harald van Dijk
05d65aec12
tests: limit number of threads to something reasonable.
Creating 1000 threads with the default stack size of 8 MiB will fail on
architectures with a 32-bit address space. Move up the existing THREADS
macro and use that instead, but change its definition to 1000 if
pointers are larger than 32 bits.

Signed-off-by: Harald van Dijk <harald@gigawatt.nl>
2020-07-07 13:37:30 +01:00
Marc-André Lureau
3f72a95925 uri: make g_uri_parse_params() take an error
This should be more future-proof.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-07 15:20:57 +04:00
Marc-André Lureau
7bee36b4ff uri: add G_FLAGS_ENCODED_QUERY
A query string may have some '=' characters '%'-encoded that could be
split by g_uri_parse_params() incorrectly. Instead, callers should leave
the query part encoded, and let g_uri_parse_params() do the decoding.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-07 15:16:44 +04:00
Marc-André Lureau
30ad9c6711 uri: teach g_uri_parse_params() to decode www-form query
This is a minor convenience, to avoid caller to do further '+' decoding.

According to the W3C HTML specification, space characters are replaced
by '+': https://url.spec.whatwg.org/#urlencoded-parsing

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-07 15:16:33 +04:00
Marc-André Lureau
e2d3349c56 tests/uri: add g_uri_parse_params() corner-cases
Add a test for empty key & empty value, and a case for missing =.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-07 15:16:30 +04:00
Marc-André Lureau
591d8676ee uri: modify g_uri_parse_params() to take flags
This will allow to further enhance the parsing, without breaking API,
and also makes argument on call side a bit clearer than just TRUE/FALSE.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-07 15:16:22 +04:00
Marc-André Lureau
d022b7199b uri: change parse_params() to take a separator set
This should give a bit more flexibility, without drawbacks.

Many URI encoding accept either '&' or ';' as separators.

Change the documentation to reflect that '&' is probably more
common (http query string).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-07 15:16:12 +04:00
Philip Withnall
4486ac1448 Merge branch 'sysprof' into 'master'
Add initial sysprof support

See merge request GNOME/glib!1551
2020-07-07 10:57:34 +00:00
Marc-André Lureau
db9987d269 strfuncs: a few g_strsplit_set() improvements
gboolean is secretly actually typedef gint gboolean, so the delim_table
is going to take 1KB of stack all by itself. That’s fine, but it could
be smaller.

This strnpbrk()-like block could do with a comment to make it a bit
clearer what it’s doing.

Suggested-by: Philip Withnall <philip@tecnocode.co.uk>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-07 14:18:48 +04:00
Philip Withnall
b08bd04abe gtask: Improve task names used internally within GLib
And improve them externally, where not otherwise set, by setting them
from the function name passed to `g_task_set_source_tag()`, if called by
third party code.

This should make profiling and debug output from GLib more useful.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-07 11:17:10 +01:00
Philip Withnall
7cd67c935f gspawn: Add sysprof trace support for spawning
Use this to replace the much-hated `g_debug()` which told people that
`posix_spawn()` (the fast path) wasn’t being used for various reasons.

If people want to make their process spawning faster now, they’ll have
to use a profiling tool like sysprof to check their program’s
performance. Shocking.

I think I was wrong to put this `g_debug()` in there in the first place
— it hasn’t served its purpose of making people speed up their spawn
paths to use `posix_spawn()`, it’s only cluttered up logs and frustrated
people.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-07 11:17:10 +01:00
Philip Withnall
6f281ce2e5 gtask: Include task name in complete_in_idle_cb source name
`complete_in_idle_cb()` shows up in a lot of sysprof traces, so it’s
quite useful to include the most specific contextual information we can
in it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-07 11:17:10 +01:00
Philip Withnall
bfe161742c gmain: Add sysprof tracing to GMainContext and GSource
This allows you to see how long each `GMainContext` iteration and each
`GSource` `check`/`prepare`/`dispatch` takes. It provides more detail
than sysprof’s speedtrack plugin can provide, since it has access to
more internal GLib data.

Use it with `sysprof-cli`, for example:
```
sysprof-cli --use-trace-fd -- my-test-program
```

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-07 11:17:10 +01:00
Philip Withnall
fa13c41da7 gtrace: Add sysprof tracing support infrastructure
Add some internal wrappers around sysprof tracing, so that it can be
used throughout GLib without exposing all the details of sysprof
internally.

This adds an optional dependency on `libsysprof-capture-4`. sysprof
support is disabled without it.

This depends on the GLib dependency of `libsysprof-capture` being
dropped in https://gitlab.gnome.org/GNOME/sysprof/-/merge_requests/30,
which has bumped the soname of `libsysprof-capture` and added subproject
support.

The next few commits will add marks that trace out each `GMainContext`
iteration and each `GSource` `check`/`prepare`/`dispatch` call.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-07 11:17:10 +01:00
Nirbheek Chauhan
1ee22d0ae9 Merge branch 'bugfix/appinfo-launch-urilist-leak' into 'master'
gdesktopappinfo: Fix unnecessarily copied and leaked URI list

See merge request GNOME/glib!1563
2020-07-05 08:53:26 +00:00
Felix Riemann
88fe78137d gdesktopappinfo: Fix unnecessarily copied and leaked URI list
When an app is spawned using g_desktop_app_info_launch_uris_with_spawn
it will expand the various token in the app's commandline with the
URIs of the files to open. The expand_macro() function that is used for
this advances the pointer to the URI list to show up to which entries
it used.

To not loose the pointer to the list head a duplicate of the URI list
was actually passed to expand_macro(). However, it's not necessary to
create a copy of the URI list for that as expand_macro() will only
change which element the pointer will point to.

This behaviour actually caused the duplicated list to be leaked as the
the list pointer is NULL once all URIs are used up by expand_macro()
and thus nothing was freed at the end of the function.
2020-07-04 20:20:42 +02:00
Philip Withnall
b101dbda13 Merge branch 'g_uri_list_extract_uris-use-pointer-array' into 'master'
gconvert: Use a pointer array in extract_uris

See merge request GNOME/glib!1561
2020-07-03 20:44:09 +00:00
Peter Bloomfield
3ef229fd03 gconvert: Use a pointer array in extract_uris
Use a GPtrArray instead of a GSList in g_uri_list_extract_uris().
2020-07-03 15:48:15 -04:00
Florentina Mușat
3bc9f57f26 Update Romanian translation 2020-07-02 09:41:21 +00:00
Sebastian Dröge
15bf2ddaf5 Merge branch 'ossfuzz-23815-23818-uri-overflows' into 'master'
Fix buffer read overflows in GUri

See merge request GNOME/glib!1559
2020-07-01 12:59:19 +00:00
Philip Withnall
f9d165add1 guri: Fix buffer overrun when decoding %-encoded URI components
There is a limited (1 or 2 byte) read off the end of the buffer if its
final or penultimate byte is `%` and it’s not nul-terminated after that.
If the buffer *is* nul-terminated then the first `g_ascii_isxdigit()`
call safely returns `FALSE` and the code moves on.

Fix it by adding an additional check, and some unit tests to catch the
behaviour.

This bug is present in libsoup, which `GUri` is based on, but not
exploitable due to how the external API only exposes nul-terminated
strings. See https://gitlab.gnome.org/GNOME/libsoup/-/merge_requests/126
for the fix there.

oss-fuzz#23815
oss-fuzz#23818

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-01 13:28:09 +01:00
Philip Withnall
67ba5bfe60 fuzzing: Test g_uri_unescape_segment() as well as g_uri_unescape_bytes()
They have different `%`-encoding behaviour, and probably both deserve to
be tested.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-01 13:28:09 +01:00
Philip Withnall
0b198104e5 tests: Test the length argument of g_uri_unescaped_bytes()
Modify the existing test function to run each test twice: once
nul-terminated and once with a length specified.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-01 13:28:09 +01:00
Philip Withnall
7656399cf9 tests: Rewrite another URI test to use an array of test strings
This introduces no functional changes, but will make it easier to add
more tests in future.

It splits the unescaping tests out so the different types of unescaping
(string, bytes, segment) are tested separately, since they have
different limitations.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-01 13:28:09 +01:00
Philip Withnall
836fee7a08 tests: Test the length argument of g_uri_parse_params()
Modify the existing test function to run each test twice: once
nul-terminated and once with a length specified.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-01 12:25:49 +01:00
Philip Withnall
67c9d34d71 guri: Allow params to be NULL if length is 0
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-01 12:25:49 +01:00
Philip Withnall
ab33896bcc tests: Rewrite a URI test to use an array of test strings
This introduces no functional changes, but will make it easier to add
more tests in future.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-01 12:25:49 +01:00
Philip Withnall
99f87d176d Merge branch 'patch-1' into 'master'
Remove c-format from the string that is not c-formatted

See merge request GNOME/glib!1555
2020-07-01 10:06:53 +00:00
Philip Withnall
f77c75a1bb Merge branch 'ossfuzz-fix-again' into 'master'
fuzzing: Another fix for g_uri_parse() test

See merge request GNOME/glib!1556
2020-06-30 10:35:53 +00:00
Philip Withnall
39f8aff8f5 fuzzing: Test URI parsing with and without the strict flag
This should test a few more code paths.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-06-30 11:10:51 +01:00
Philip Withnall
0bf12c8bfa fuzzing: Use nul-terminated array introduced in previous commit
This fixes commit b2a6a9a434. Doh.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-06-30 11:08:05 +01:00
Daniel Mustieles
f1a9599bcd Updated Spanish translation 2020-06-30 09:44:13 +02:00
Daniel Mustieles
3cb19804a0 Updated Spanish translation 2020-06-29 15:56:30 +02:00
Yuri Chornoivan
a910513873 Update Ukrainian translation 2020-06-29 13:06:49 +00:00
Yuri Chornoivan
4fe91b63a3 Remove c-format from the string that is not c-formatted 2020-06-29 13:02:44 +00:00
Sebastian Dröge
18b89c1486 Merge branch 'uri-parsing-fix' into 'master'
GUri build fixes

See merge request GNOME/glib!1554
2020-06-29 11:24:17 +00:00
Philip Withnall
b2a6a9a434 fuzzing: Ensure input to g_uri_parse() is nul-terminated
The fuzzer will produce arbitrary binary blobs, which might not be
nul-terminated. `g_uri_parse()` has no length argument, so relies on
receiving a nul-terminated string as input. Guarantee that.

This should fix fuzzing build failures like
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23750.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-06-29 11:52:40 +01:00