Commit Graph

24258 Commits

Author SHA1 Message Date
Philip Withnall
f2609eaa1a Merge branch 'move_dirname_tests' into 'main'
Moving tests/dirname-test.c to glib/tests/fileutils.c

See merge request GNOME/glib!2397
2021-12-16 11:14:47 +00:00
Emmanuel Fleury
9f760a7cc1 Moving tests/dirname-test.c to glib/tests/fileutils.c
Helps issue #1434
2021-12-16 10:41:13 +00:00
Philip Withnall
dce8d110d6 Merge branch 'move_tests/child-test_to_glib/tests/spawn-multithreaded' into 'main'
Merging tests/child-test.c into glib/tests/spawn-multithreaded.c

See merge request GNOME/glib!2390
2021-12-16 10:38:53 +00:00
Philip Withnall
11767ed96c Merge branch 'barch/glist_position_unspecified_behavior' into 'main'
fix /list/position test

See merge request GNOME/glib!2398
2021-12-16 09:47:03 +00:00
Charles Barto
d60b4010c4 Silence MSVC C4312 in list tests
This warning warns on widening casts from integer to pointer type,
because those casts can be problematic for porting to new pointer
sizes. The code in question didn't do any bad things here so an
intermediate cast to size_t was added to silence the warning
2021-12-15 17:21:20 -08:00
Charles Barto
cdd53b9218 fix /list/position test
This test was exploiting unspecified behavior w.r.t. the address of string
literals, It expected them to be pooled (the same literal has the same
address, at least within a TU), but MSVC does not pool by default,
leading to a failure.
2021-12-15 17:19:50 -08:00
Emmanuel Fleury
45bd6e1d3d Improving the tests moved in spawn-multithreaded 2021-12-16 00:55:42 +01:00
Hugo Carvalho
5aafb1f21f Update Portuguese translation 2021-12-15 23:21:04 +00:00
Emmanuel Fleury
241b9f41b4 Merging tests/child-test.c into glib/tests/spawn-multithreaded.c
Helps issue #1434
2021-12-15 23:12:59 +01:00
Yuri Chornoivan
a7a80d9855 Update Ukrainian translation 2021-12-15 19:04:20 +00:00
Philip Withnall
5462612dc3 Merge branch 'mcatanzaro/posix-spawn2' into 'main'
gspawn: Implement fd remapping for posix_spawn codepath, and fix file descriptor conflation issues

Closes #2503 and #2506

See merge request GNOME/glib!1968
2021-12-15 08:17:29 +00:00
Michael Catanzaro
376e2915e2 Add test for child_err_report_fd conflation with target fds
This tests for glib#2506.
2021-12-14 13:47:31 -06:00
Michael Catanzaro
d4c486779d Add tests for GSubprocess fd conflation issues
This tests for #2503. It's fragile, but there is no non-fragile way to
test this. If the test breaks in the future, it will pass without
successfully testing the bug, not fail spuriously, so I think this is
OK.
2021-12-14 13:47:31 -06:00
Michael Catanzaro
b251a7cd18 gspawn: add new error message for open() failures
Reporting these as dup2() failures is bogus.
2021-12-14 13:45:39 -06:00
Michael Catanzaro
34de33a9bd gspawn: Check from errors from safe_dup2() and dupfd_cloexec()
Although unlikely, these functions can fail, e.g. if we run out of file
descriptors. Check for errors to improve robustness. This is especially
important now that I changed our use of dupfd_cloexec() to avoid
returning fds smaller than the largest fd in target_fds. An application
that attempts to remap to the highest-allowed fd value deserves at least
some sort of attempt at error reporting, not silent failure.
2021-12-14 13:45:39 -06:00
Michael Catanzaro
2a7547f8a5 gsubprocess: ensure we test fd remapping on the posix_spawn() codepath
We should run test_pass_fd twice, once using gspawn's fork/exec codepath
and once attempting to use its posix_spawn() codepath. There's no
guarantee we'll actually get the posix_spawn() codepath, but it works
for now on Linux.

For good measure, run it a third time with no flags at all.

This causes the test to fail if I separately break the fd remapping
implementation. Without this, we fail to test fd remapping on the
posix_spawn() codepath.
2021-12-14 13:45:39 -06:00
Michael Catanzaro
7d5bdff6d9 gspawn: Implement fd remapping for posix_spawn codepath
This means that GSubprocess will (sometimes) be able to use the
optimized posix_spawn codepath instead of having to fall back to
fork/exec.
2021-12-14 13:45:39 -06:00
Michael Catanzaro
f9780c6bee gspawn: fix fd remapping conflation issue
We currently dup all source fds to avoid possible conflation with the
target fds, but fail to consider that the result of a dup might itself
conflict with one of the target fds. Solve this the easy way by duping
all source_fds to values that are greater than the largest fd in
target_fds.

Fixes #2503
2021-12-14 13:45:39 -06:00
Michael Catanzaro
e2700c7638 gspawn: fix hangs when duping child_err_report_fd
In case child_err_report_fd conflicts with one of the target_fds, the
code here is careful to dup child_err_report_fd in order to avoid
conflating the two. It was a good idea, but evidently was not tested,
because the newly-created fd is not created with CLOEXEC set. This means
it stays open in the child process, causing the parent to hang forever
waiting to read from the other end of the pipe. Oops!

The fix is simple: just set CLOEXEC. This removes our only usage of the
safe_dup() function, so it can be dropped.

Fixes #2506
2021-12-14 13:36:26 -06:00
Michael Catanzaro
33f15d9dd0 gspawn: Improve error message when dup fails
This error message is no longer accurate now that we allow arbitrary fd
remapping.
2021-12-14 13:36:25 -06:00
Michael Catanzaro
ac8d1aa247 gspawn: use close_and_invalidate more 2021-12-14 13:36:24 -06:00
Philip Withnall
2c07c17840 Merge branch 'datetime_tests' into 'main'
Removing unnecessary test on gdatetime.c

See merge request GNOME/glib!2393
2021-12-14 15:25:40 +00:00
Philip Withnall
f493d3fd24 Merge branch 'cxx-test' into 'main'
Removing redundant cxx test tests/cxx-test.cpp

See merge request GNOME/glib!2391
2021-12-14 15:23:16 +00:00
Emmanuel Fleury
ae345e56c2 Distribute cxx test tests/cxx-test.cpp to each module tests directory
tests/cxx-test.cpp is removed and splitted into gio/tests/cxx.cpp,
gmodule/tests/cxx.cpp and gobject/tests/cxx.cpp.

Helps issue #1434
2021-12-14 14:43:03 +01:00
Emmanuel Fleury
6a17b114b6 Removing unnecessary test on gdatetime.c
Helps issue #1434
2021-12-14 13:46:06 +01:00
Philip Withnall
6616fb7798 Merge branch 'main' into 'main'
GDesktopAppInfo: Try to always correctly set id

See merge request GNOME/glib!2283
2021-12-14 12:10:06 +00:00
Aurimas Černius
c7e88785f3 Updated Lithuanian translation 2021-12-14 13:51:52 +02:00
Ivaylo Dimitrov
f065497acf GDesktopAppInfo: Try to always correctly set id
Specs say that on Unix id should be desktop file id from the xdg menu
specification, however, currently code just uses basename of .desktop file.
Fix that by finding the .desktop file in all the desktop_file_dirs and use
basename only as a fallback.

See https://specifications.freedesktop.org/menu-spec/latest/go01.html#term-desktop-file-id
and https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s02.html#desktop-file-id

"To determine the ID of a desktop file, make its full path relative to the
$XDG_DATA_DIRS component in which the desktop file is installed, remove the
"applications/" prefix, and turn '/' into '-'."

Also, add unit test that verifies Desktop Id is being correctly set

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
2021-12-14 11:46:57 +00:00
Philip Withnall
62be185463 Merge branch 'moving_completion_tests' into 'main'
Move tests/completion-test.c to glib/tests/completion.c

See merge request GNOME/glib!2392
2021-12-14 11:37:46 +00:00
Emmanuel Fleury
cde56cfc70 Move tests/completion-test.c to glib/tests/completion.c
Helps issue #1434
2021-12-13 17:42:23 +01:00
Aurimas Černius
ce57cc1c02 Updated Lithuanian translation 2021-12-11 21:08:29 +02:00
Philip Withnall
67dad10fb8 Merge branch 'xlocale-musl' into 'main'
gstrfuncs: don't require nonstandard functions for USE_XLOCALE.

Closes #2553

See merge request GNOME/glib!2388
2021-12-10 13:05:53 +00:00
Daniel Șerbănescu
44397add95 Update Romanian translation
(cherry picked from commit 409326e1d4)
2021-12-10 10:19:51 +00:00
Érico Nogueira
4b2f342a22 gstrfuncs: don't require nonstandard functions for USE_XLOCALE.
Make it so USE_XLOCALE is set whenever newlocale() and uselocale() are
available. This way, we can still use the _g_snprintf() path for some
functions, and also use the *_l functions when they are available.

newlocale(3) are uselocale(3) part of POSIX 2008, while the *_l
functions being used are nonstandard glibc extensions. Gating all the
locale functionality behind them meant we were using fallbacks on non
glibc platforms unnecessarily.

Further changes to this code could add fallback for the non _l suffixed
number parsing functions, but that might be unnecessary complexity.

Fixes #2553
2021-12-09 18:20:07 -03:00
Sebastian Dröge
6c938587d9 Merge branch 'project-docs' into 'main'
docs: Update the README a little

See merge request GNOME/glib!2387
2021-12-09 16:17:59 +00:00
Philip Withnall
568291b371 docs: Update the README a little
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2021-12-09 13:30:23 +00:00
Sebastian Dröge
e3e3c02bd2 Merge branch 'readme-docs' into 'main'
docs: Add API documentation links to the README

See merge request GNOME/glib!2386
2021-12-08 15:37:45 +00:00
Philip Withnall
1acef5a4e4 docs: Add API documentation links to the README
Might make the API documentation a little easier to find from the GitLab
landing page for GLib.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-12-08 14:48:35 +00:00
Andika Triwidada
84464d82fa Update Indonesian translation 2021-12-05 04:11:51 +00:00
Sebastian Dröge
4d2a76af69 Merge branch 'file-utils-minor-fixes' into 'main'
gfileutils: Fix transfer annotation and whitespace issues

See merge request GNOME/glib!2385
2021-12-03 15:40:30 +00:00
Phaedrus Leeds
93f5758cf4 gfileutils: Fix transfer annotation and whitespace issues 2021-12-02 12:37:26 -08:00
Sebastian Dröge
9538e05387 Merge branch 'ossfuzz-41563-canonical-triple-slash-dot-dot' into 'main'
gfileutils: Correctly reset start value when canonicalising paths

See merge request GNOME/glib!2382
2021-12-02 18:46:06 +00:00
Philip Withnall
fc25f8d7ef gfileutils: Correctly reset start value when canonicalising paths
If a path starts with more than two slashes, the `start` value was
previously incorrect:
 1. As per the `g_path_skip_root()` call, `start` was set to point to
    after the final initial slash. For a path with three initial
    slashes, this is the character after the third slash.
 2. The canonicalisation loop to find the first dir separator sets
    `output` to point to the character after the first slash (and it
    overwrites the first slash to be `G_DIR_SEPARATOR`).
 3. At this point, with a string `///usr`, `output` points to the second
    `/`; and `start` points to the `u`. This is incorrect, as `start`
    should point to the starting character for output, as per the
    original call to `g_path_skip_root()`.
 4. For paths which subsequently include a `..`, this results in the
    `output > start` check in the `..` loop below not skipping all the
    characters of a preceding path component, which is then caught by
    the `G_IS_DIR_SEPARATOR (output[-1])` assertion.

Fix this by resetting `start` to `output` after finding the final slash
to keep in the output, but before starting the main parsing loop.

Relatedly, split `start` into two variables: `after_root` and
`output_start`, since the variable actually has two roles in the two
parts of the function.

Includes a test.

This commit is heavily based on suggestions by Sebastian Wilhemi and
Sebastian Dröge.

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

oss-fuzz#41563
2021-12-02 17:50:17 +00:00
Quentin PAGÈS
e3d28f8b80 Update Occitan translation
(cherry picked from commit 711efa507b)
2021-12-02 15:06:08 +00:00
Philip Withnall
3421a703ca gfileutils: Add a comment in g_canonicalize_filename()
Clarify the code a little. This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-12-02 11:32:25 +00:00
Sebastian Dröge
5ab008a50c Merge branch 'bit-test-improvements' into 'main'
tests: Test the function forms of g_bit_*() APIs too

See merge request GNOME/glib!2381
2021-12-02 10:21:59 +00:00
Philip Withnall
cbd48824bd tests: Test the function forms of g_bit_*() APIs too
The tests were previously only checking the macro forms. The function
forms should behave identically, but since it’s easy enough to get
coverage of them, we might as well.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-12-02 10:02:57 +00:00
Philip Withnall
d5e6793b83 tests: Factor out common calculations in test_basic_bits() test
This decreases the overall test time from 0.17s to 0.12s for me, and
will help further in the following commit where I’m going to repeat some
of these calculations again for further comparisons.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-12-02 09:59:46 +00:00
Philip Withnall
17ffe7b303 Merge branch 'move_bit-test' into 'main'
Merging tests/bit-test.c into glib/tests/utils.c

See merge request GNOME/glib!2379
2021-12-02 09:45:37 +00:00
Emmanuel Fleury
dd47df80e1 Merging tests/bit-test.c into glib/tests/utils.c 2021-12-01 14:10:44 +01:00