Commit Graph

24510 Commits

Author SHA1 Message Date
Philip Withnall
a6311f81ee gtestutils: Handle empty argv array passed to g_test_init()
This can happen if a caller (ab)uses `execve()` to execute a gtest
process with an empty `argv` array. `g_test_init()` has to gracefully
handle such a situation.

Fix a few problem areas in the code, and add a simple test which checks
that `g_test_init()` doesn’t crash when called with an empty `argv`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:47:19 +00:00
Philip Withnall
44f4d55150 gspawn: Clarify that empty argv arrays are not allowed when spawning
While `execve()` might allow (probably malicious) users to execute a
program with an empty `argv` array, gspawn does not. It’s not actually
possible, as the path to the binary to execute is not specified
separately from the argument array.

Explicitly document and encode that in preconditions.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:43 +00:00
Philip Withnall
18fc711355 gshell: Mention handling of empty argv arrays in the documentation
It is not possible for `g_shell_parse_argv()` to return an empty `argv`
array. Make that clear in the documentation and add some assertions to
encode it explicitly in the code.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:43 +00:00
Philip Withnall
11654811ef gdesktopappinfo: Add checks for empty argv
There shouldn’t be any issues here with empty argv arrays since an empty
`Exec=` line is already checked for. Encode that explicitly with an
assertion.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:42 +00:00
Philip Withnall
3ea4ba31a1 tools: Fix handling of empty argv in various minor GLib tools
This won’t really affect anything, but we might as well fix them to not
crash if called with an empty `argv` by someone (ab)using `execve()`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:42 +00:00
Philip Withnall
0d743e7ffb gapplicationcommandline: Handle the possibility empty args in an example
While it’s not usual, it is possible for applications to be called with
an empty `argv` by a process (ab)using `execve()`. Modify the
`GApplication` code example to handle that possibility, so that anyone
copying the example isn’t introducing a bug into their program
immediately.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:42 +00:00
Philip Withnall
fc6d0ba3a8 gapplicationcommandline: Fix a typo in a documentation comment
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-11 14:45:42 +00:00
Philip Withnall
1094bfc7d7 Merge branch 'wip/smcv/defer-test-cleanup' into 'main'
testutils: Defer global cleanup until we really exit

Closes #2563

See merge request GNOME/glib!2420
2022-02-11 14:21:43 +00:00
Philip Withnall
f2d67f3605 gtestutils: Mark a variable as const
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

See: !2420
2022-02-11 13:04:06 +00:00
Simon McVittie
00b17c92bf Add a test-case for calling g_test_build_filename after g_test_run
This will not reproduce the bug when run as a unit test, because in that
scenario, G_TEST_BUILDDIR and G_TEST_SRCDIR are set. It *can* reproduce
the bug (at least probabilistically) when run as an installed-test,
or manually in a build tree:

    ./_build/glib/tests/testing

Reproduces: https://gitlab.gnome.org/GNOME/glib/-/issues/2563
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-11 13:04:06 +00:00
Philip Withnall
6fd53df562 Merge branch 'wip/hadess/timer-docs' into 'main'
gtestutils: Mention the unit used for the test timer

See merge request GNOME/glib!2378
2022-02-11 12:46:15 +00:00
Philip Withnall
a71ed21116 Merge branch 'unicode-script-math' into 'main'
Add G_UNICODE_SCRIPT_MATH to GUnicodeScript

See merge request GNOME/glib!2476
2022-02-11 12:42:55 +00:00
Alexis King
e85a085ca4 Add G_UNICODE_SCRIPT_MATH to GUnicodeScript 2022-02-11 12:42:55 +00:00
Philip Withnall
95c6f3dc38 Merge branch '2329-application-cli-parsing' into 'main'
gapplication: Expose zero-valued numbers in handle-local-options

Closes #2329

See merge request GNOME/glib!1953
2022-02-11 12:40:37 +00:00
Matheus Barbosa
14e0eab02a Update Brazilian Portuguese translation 2022-02-10 20:20:19 +00:00
Sebastian Dröge
cfd245bc78 Merge branch 'test-skip-fix-win32' into 'main'
tests: Use g_test_skip() to skip a test on Windows

See merge request GNOME/glib!2484
2022-02-10 13:40:28 +00:00
Philip Withnall
0c27ac8287 tests: Use g_test_skip() to skip a test on Windows 2022-02-10 13:40:28 +00:00
Hugo Carvalho
484c884469 Update Portuguese translation 2022-02-10 13:35:57 +00:00
Nirbheek Chauhan
a93a8db5d3 Merge branch 'w32-tests-datetime' into 'main'
Fix glib/tests/gdatetime on win32

See merge request GNOME/glib!2483
2022-02-10 09:43:26 +00:00
Marc-André Lureau
32f514b0fa glib/tests: skip more tests that depend on installed translations
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-10 12:44:59 +04:00
Marc-André Lureau
6d21ff6305 glib/tests: skip test that aborts with plain Windows UCRT
setlocale() asserts on LC_MESSAGES:
minkernel\crts\ucrt\src\appcrt\locale\wsetlocale.cpp(448) : Assertion failed: LC_MIN <= _category && _category <= LC_MAX

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale
https://developercommunity.visualstudio.com/t/setlocale-assert-on-invalid-category/1646244

(apparently, MinGW wraps or reimplements the call)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-10 12:44:59 +04:00
Marc-André Lureau
9e9e323a2d glib/tests: set DE ThreadLocale to fix a test
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-10 12:44:59 +04:00
Marc-André Lureau
2761e13446 glib/tests: skip some tests if langinfo isn't available
The fallback win32 code doesn't seem to be localized.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-10 12:44:59 +04:00
Marc-André Lureau
60e7430c80 glib/tests: skip rfc8536 file parsing on Windows
This is specific to Unix, as far as I can tell.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-10 12:44:56 +04:00
Nirbheek Chauhan
7800d1056f Merge branch 'w32-tests-fileutils' into 'main'
Fix glib/tests/fileutils on win32

See merge request GNOME/glib!2481
2022-02-10 07:36:13 +00:00
Kukuh Syafaat
005a536adc Update Indonesian translation 2022-02-10 02:51:37 +00:00
Marc-André Lureau
1713dd0a91 tests: skip read-only-directory test on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-10 01:05:46 +04:00
Marc-André Lureau
354c454c56 tests: fix read-only-file test
The test is meant to check read-only files don't get overwritten, which
is 0400 in octal.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-10 01:04:30 +04:00
Marc-André Lureau
59b226d272 tests: use g_chmod in fileutils tests
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-10 00:36:46 +04:00
Marc-André Lureau
5f4e8f625d tests: fix test_set_contents_full error test on win32
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-10 00:36:46 +04:00
Marc-André Lureau
a4e302f503 tests: fix test_set_contents_full mode check on win32
Fixes:
GLib:ERROR:../glib/tests/fileutils.c:1348:test_set_contents_full: assertion failed (statbuf.st_mode & ~S_IFMT == tests[i].new_mode): (438 == 420)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-10 00:36:46 +04:00
Marek Černocký
3cafc636fe Updated Czech translation 2022-02-09 20:51:07 +01:00
Luming Zh
90ccbcc0a8 Update Chinese (China) translation 2022-02-09 16:01:38 +00:00
Yuri Chornoivan
b965f8d64c Update Ukrainian translation 2022-02-09 14:51:04 +00:00
Philip Withnall
e74d6f4552 Merge branch 'test_two_digit_years' into 'main'
Improve coverage of two digit years in gdate tests

See merge request GNOME/glib!2477
2022-02-09 11:40:52 +00:00
Philip Withnall
ebf64a5024 Merge branch 'w32-spawn-fds' into 'main'
Implement fd passing for Windows spawn

See merge request GNOME/glib!2458
2022-02-09 11:19:16 +00:00
Kukuh Syafaat
2ea9f4b0d3 Update Indonesian translation 2022-02-09 03:05:08 +00:00
Emmanuel Fleury
d2e86d806c Improve coverage of two digit years in gdate tests 2022-02-08 23:35:59 +01:00
Philip Withnall
91a12c4927 Merge branch 'deprecate-force_posix_threads' into 'main'
build: deprecate force_posix_threads build option

Closes #2592

See merge request GNOME/glib!2474
2022-02-08 13:15:33 +00:00
Christoph Reiter
17a5958f79 build: deprecate force_posix_threads build option 2022-02-08 13:15:33 +00:00
Marc-André Lureau
e05227371d glib/win32: fix passing same fd for stdout & stderr spawn
Delay closing the FDs after all input FDs are duped.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-07 23:39:36 +04:00
Marc-André Lureau
2d35c57718 glib/win32: implement fd passing with g_spawn_async_with_pipes_and_fds
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-07 23:39:36 +04:00
Marc-André Lureau
674072b139 glib/win32: check if dup() failed in helper process
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-07 23:31:22 +04:00
Marc-André Lureau
34ce1b1f93 glib/spawn: win32 helper doesn't support same fd for out&err
This is fixed in the following commits of this MR.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-07 23:31:10 +04:00
Marc-André Lureau
10b450eaf6 glib/tests: make fd-assignment-clash run on win32
This is a minimal test for g_spawn_async_with_pipes_and_fds()

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-07 23:30:37 +04:00
Marc-André Lureau
8309872111 glib/tests: fix compilation with MSVC
glib/tests/spawn-singlethread.c(439): error C2057: expected constant expression

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-02-07 23:30:37 +04:00
Philip Withnall
50d23f9680 Merge branch 'feature/move_async' into 'main'
Implement async file movement

See merge request GNOME/glib!2469
2022-02-07 14:29:52 +00:00
Lucas Schwiderski
9efde4c7fc Add test for async file move 2022-02-07 14:04:04 +00:00
Lucas Schwiderski
966f887cf9 Rename ambiguous struct 2022-02-07 14:03:47 +00:00
Lucas Schwiderski
eeb2bcf5a9 Implement async file movement 2022-02-07 14:03:47 +00:00