Commit Graph

26645 Commits

Author SHA1 Message Date
Ray Strode
4a00ac91c6 tests: Shorten internal codegen test timeout
the gio dbus codegen test has 10 test cases in it.
Each test case is given 100 seconds to complete.

That is far longer than they should need.

Furthermore, the entire test is only given 60s
to complete.

This commit makes the internal timeout more consistent
with the external timeout, by giving each of the 10
test cases 6 seconds instead of 100s.
2022-11-08 13:08:53 -05:00
Philip Withnall
6e57afdefd Merge branch '2782-variant-maybe-wrapper-speedup' into 'main'
gvariant-parser: Speed up maybe_wrapper() by an order of magnitude

Closes #2782

See merge request GNOME/glib!3061
2022-11-08 17:11:07 +00:00
Philip Withnall
482e9cd9e3 Merge branch 'reuse-regressions-ci' into 'main'
ci: Add a CI check for REUSE-compliant licensing/copyright headers

See merge request GNOME/glib!3051
2022-11-08 16:30:12 +00:00
Philip Withnall
9ae59bd647 gvariant-parser: Speed up maybe_wrapper() by an order of magnitude
This further helps with the potential denial of service problem in
issue #2782 / oss-fuzz#49462 / oss-fuzz#20177.

Instead of allocating a new `GVariant` for each nesting level of
maybe-types, allocate a single `GVariant` and give it the fully-nested
maybe type as its type. This has to be done in serialised form.

This prevents attackers from triggering O(size of container × typedecl
depth) allocations.

This is a follow up to commit 3e313438f1,
and includes a test.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Fixes: #2782
oss-fuzz#20177
oss-fuzz#49462
2022-11-08 16:14:02 +00:00
Philip Withnall
1e7b20d68a Merge branch 'variant-spec-updates' into 'main'
docs: Add licensing/copyright data to GVariant specification and fix various formatting issues

See merge request GNOME/glib!3048
2022-11-08 16:13:59 +00:00
Philip Withnall
b906d470c7 ci: Add a CI check for REUSE-compliant licensing/copyright headers
This doesn’t enforce licensing/copyright headers to be present on all
files, but does check that at least a minimum number of files are
correct.

This should help avoid new files being added without appropriate
licensing information in future.

The baseline is set at what `reuse lint` outputs for me at the moment.

See https://reuse.software/tutorial/#step-2 for information about how to
add REUSE-compliant licensing/copyright to files.

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

Helps: #1415
2022-11-08 15:50:59 +00:00
Philip Withnall
b7c497eedb docs: Fix a broken link in the GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
e039a30ef1 docs: Add a manual revision history to the GVariant Specification
This will make it clear what the bigger changes are between versions.
Kind of like a `NEWS` file for the specification.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
f518d78fd7 docs: Add links to the D-Bus specification to the GVariant Specification
This should clarify object paths and signatures a little, if anyone
needs that. This introduces no semantic changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
227bb51a74 docs: Change ‘DBus’ to ‘D-Bus’ in the GVariant Specification
That’s how it’s meant to be formatted.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
bf4bab98f7 docs: Fix forall formatting in GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
106ef532fc docs: Improve Python code snippet formatting in GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
fa823ea3b4 docs: Minor improvement of word choice in the GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
950e8991cd docs: Remove another dangling reference from the GVariant Specification
This is another reference to an omitted part of Allison’s thesis.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
6d8349a9ff docs: Fix subsection capitalisation consistency in GVariant Spec
The other subheadings here are in Title Case.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
59620c9cf8 docs: Fix a cross-reference to a Figure in the GVariant Specification
reStructuredText doesn’t support cross-references unless always built
with Sphinx (as I understand it). `rst2html5` doesn‘t support them.

So reword this (currently manual) cross-reference so it’s less awkward.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
aa568abb97 docs: Fix a minor typo in the GVariant Specification
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
ca45f84789 docs: Fix references to omitted requirements in GVariant Specification
I believe the specification was originally a shorter extract of
Allison’s thesis. This left a few dangling references to requirements
which were listed in a part of the thesis not included in the
specification.

Reword them slightly so they’re not quite so awkward.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Philip Withnall
e34fdb0cd5 docs: Add licensing/copyright data to GVariant specification
The licensing for the original GVariant specification was not specified
in the original PDF.

However, CC-BY-SA-3.0 has been agreed by Allison, the sole copyright
holder, here:

https://gitlab.gnome.org/Teams/documentation/developer-www/-/merge_requests/108/#note_1586866

The diagrams were redrawn by me, so their licensing/copyright status is
clear.

Tested with `reuse lint` to ensure the data is machine-readable.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:46:16 +00:00
Simon McVittie
3e1074f403 Merge branch 'misc-variant-fixes' into 'main'
tests: Fix a small leak in the GVariant tests and some minor documentation typos

See merge request GNOME/glib!3062
2022-11-08 15:43:58 +00:00
Philip Withnall
64f5e3ab2d gvariant: Fix some minor typos in documentation comments
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:16:50 +00:00
Philip Withnall
6db82d98d3 tests: Fix a small leak in the GVariant tests
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-08 15:16:50 +00:00
Philip Withnall
e2b9e28ece Merge branch 'wip/3v1n0/meson-fix-tests-binary-dependencies' into 'main'
test/meson: Add tests dependencies on built programs, libraries and modules

See merge request GNOME/glib!3015
2022-11-08 12:30:53 +00:00
Philip Withnall
9a0c8a585d Merge branch 'mkenums' into 'main'
glib-mkenums: feature use of previous symbols in evaluation

See merge request GNOME/glib!3043
2022-11-08 11:12:40 +00:00
Simon McVittie
2487fe2258 Merge branch 'fuzz-utf8-validate' into 'main'
fuzzing: Add a fuzz test for g_utf8_validate()

See merge request GNOME/glib!3060
2022-11-07 15:23:37 +00:00
Philip Withnall
42c9e8218b gio: Change content type of zero-sized files to application/x-zerosize
That’s what xdgmime uses for zero-sized files (see `XDG_MIME_TYPE_EMPTY`).

Historically, GLib explicitly used `text/plain` for empty files, to
ensure they would open in a text editor. But `text/plain` is not really
correct for an empty file: the content isn’t text because there is no
content. The file could eventually become something else when written
to.

Text editors which want to be opened for new, empty files should add
`application/x-zerosize` to their list of supported content types.

Users who want to set a handler for `application/x-zerosize` on their
desktop should use
```sh
gio mime application/x-zerosize  # to see the current handler
gio mime application/x-zerosize org.gnome.gedit.desktop  # to set it
```

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

Fixes: #2777
2022-11-07 13:21:28 +00:00
Philip Withnall
46259f612e fuzzing: Add a fuzz test for g_utf8_validate()
Since it’s used extensively and has to handle untrusted arbitrary binary
input.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-07 13:20:32 +00:00
Philip Withnall
4b561a908f Merge branch '2802-drop-g-os-darwin' into 'main'
Revert "meson: Define G_OS_DARWIN when compiling under OSX or iOS"

Closes #2802

See merge request GNOME/glib!3047
2022-11-07 13:03:16 +00:00
Philip Withnall
7c72e24d38 Merge branch 'no-interupt-close' into 'main'
[Darwin] Use the non-cancelable variant of close().

Closes #2783

See merge request GNOME/glib!3041
2022-11-07 13:01:48 +00:00
John Ralls
06650545dd [Darwin] Use the non-cancelable variant of close(). 2022-11-07 13:01:47 +00:00
Philip Withnall
5af339aedf gio: Check __APPLE__ in a few places instead of HAVE_COCOA
`HAVE_COCOA` should be used only in the places where we’re actually
depending on the Cocoa toolkit. It should not be used as a general way
of detecting building on a Darwin-based OS such as macOS.

Conversely, there are a few places in the code where we do want to
specifically detect the Cocoa toolkit (and others where we specifically
want to detect Carbon), so keep `HAVE_COCOA` and `HAVE_CARBON` around.

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

Helps: #2802
2022-11-07 11:30:32 +00:00
Philip Withnall
ad4c59c3c6 docs: Mention __APPLE__ instead of G_OS_DARWIN for detecting Darwin
See discussion on #2802 and in the previous two commits.

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

Fixes: #2802
2022-11-07 11:30:32 +00:00
Philip Withnall
9ebb491d55 Revert "meson: Define G_OS_DARWIN when compiling under OSX or iOS"
This reverts commit e85635daa0.

See the previous revert for rationale.

Fixes: #2802
2022-11-07 11:30:32 +00:00
Philip Withnall
7b52ccbfc4 Revert "gio, glib: Use G_OS_DARWIN for code that is for such environments"
This reverts commit 476e33c3f3.

We’ve decided to remove `G_OS_DARWIN` in favour of recommending people
use `__APPLE__` instead. As per the discussion on #2802 and linked
issues,
 * Adding a new define shifts the complexity from “which of these
   platform-provided defines do I use” to “which platform-provided
   defines does G_OS_DARWIN use”
 * There should ideally be no cases where a user of GLib has to use
   their own platform-specific code, since GLib should be providing
   appropriate abstractions
 * Providing a single `G_OS_DARWIN` to cover all Apple products (macOS
   and iOS) hides the complexity of what the user is actually testing:
   are they testing for the Mach kernel, the Carbon and/or Cocoa user
   space toolkits, macOS vs iOS vs tvOS, etc

Helps: #2802
2022-11-07 11:30:32 +00:00
Simon McVittie
483b6f2214 Merge branch 'heed-warnings-so-they-dont-have-to' into 'main'
ci: Build with -Wnonnull

See merge request GNOME/glib!3058
2022-11-04 20:21:00 +00:00
Ray Strode
57a510df86 Merge branch 'old-fixes-solve-new-problems' into 'main'
macros: generate uniq variable name in _G_BOOLEAN_EXPR()/G_LIKELY()

Closes #1211

See merge request GNOME/glib!3059
2022-11-04 19:29:57 +00:00
Ray Strode
69b410c58a tests: Test g_str_has_prefix inside G_UNLIKELY
g_str_has_prefix uses G_UNLIKELY itself, and up
until recently, G_UNLIKELY could not be nested.

This commit adds a test that nests G_UNLIKELY to
make sure it continues to work going forward.
2022-11-04 15:07:58 -04:00
Thomas Haller
73bd146409 macros: generate uniq variable name in _G_BOOLEAN_EXPR()/G_LIKELY()
This avoids a -Wshadow warning when nesting G_LIKELY() inside
each other due to _g_boolean_var_.

This can be easily encountered when using macros:

```
    #define GET_VALUE(arg) \
        ({ \
           typeof (arg) _arg = (arg); \
           \
           g_assert (_arg); \
           get_value (_arg); \
        })
    g_assert (GET_VALUE (a) > 5);
```

__COUNTER__ is a GCC extension, but the definition of _G_BOOLEAN_EXPR()
is already inside a

  #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)

block.

Closes: #1211
2022-11-04 15:07:58 -04:00
Ray Strode
f11b96f255 ci: Build with -Wnonnull
-Wnonnull is sort of fickle and it's an option a lot of consumers
of glib use.

This commit makes sure it gets used on linux during CI as well, so
we can catch compat problems before they hit our users.
2022-11-04 14:06:48 -04:00
Michael Catanzaro
79b06ab34f Merge branch 'work-back-in-the-work-around' into 'main'
Fix build with -Werror=nonnull

Closes #2807

See merge request GNOME/glib!3057
2022-11-04 17:33:00 +00:00
Ray Strode
48730d2b30 gstrfuncs: Add back x + !x warning workaround
We thought we could drop the x + !x workaround in
commit eea87eff3f but apparently
not.

This commit adds it back, but with an added layer of indirection,
for aesthetics.

Closes: #2807
2022-11-04 13:13:13 -04:00
Ray Strode
05750454d5 gstrfuncs: Use less tristates in g_str_has_*
tri-state conditionals are kind of hard to read, especially
when they're nested.

This commit changes g_str_has_* macros to use if statements
instead.
2022-11-04 13:02:01 -04:00
Simon McVittie
66a6fedca3 Merge branch 'mcatanzaro/#2805' into 'main'
gtask: don't use g_task_set_static_name() unless allowed

Closes #2805

See merge request GNOME/glib!3056
2022-11-04 09:22:43 +00:00
Michael Catanzaro
24f2cfba25 gtask: don't use g_task_set_static_name() unless allowed
Need to check GLIB_VERSION_MIN_REQUIRED before inlining use of something
newer.

Fixes #2805
2022-11-03 19:06:40 -05:00
Ray Strode
98c3c3397c Merge branch 'sometimes-theres-extra-strings-attached' into 'main'
gstrfuncs: Make g_str_has_* more robust against non-idempotent inputs

Closes #2784

See merge request GNOME/glib!3054
2022-11-03 23:24:44 +00:00
Ray Strode
eea87eff3f gstrfuncs: Make g_str_has_* more robust against non-idempotent inputs 2022-11-03 23:24:44 +00:00
Ray Strode
877e86895e Merge branch 'wip/smcv/msvc-ebadf' into 'main'
fileutils test: Use no-op invalid-parameter handler when exercising EBADF

See merge request GNOME/glib!3055
2022-11-03 21:26:57 +00:00
Simon McVittie
1dd11faaea fileutils test: Use no-op invalid-parameter handler when exercising EBADF
This is basically !3036, but wasn't included there because !3036
and !3027 were developed in parallel.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-03 20:39:37 +00:00
Simon McVittie
201c920cbd Merge branch 'fix-fileutils-test' into 'main'
Clean up Windows Invalid Parameter Handler setup and fix fileutils test

Closes #2800

See merge request GNOME/glib!3036
2022-11-02 22:59:14 +00:00
Simon McVittie
65c7758087 Merge branch 'wip/smcv/autofd' into 'main'
gstdio: Preserve errno in g_autofd, document async-signal safety

See merge request GNOME/glib!3027
2022-11-02 21:39:53 +00:00