Commit Graph

22943 Commits

Author SHA1 Message Date
Philip Withnall
50a3d0bf9d gdatetime: Use isnan() instead of !isfinite()
Both are provided by libm, but `isnan()` is provided as a macro, whereas
`isfinite()` is an actual function, and hence libm has to be available
at runtime. That didn’t trivially work on FreeBSD, resulting in this
refactor.

`isfinite(x)` is equivalent to `!isnan(x) && !isinfinite(x)`. The case
of `x` being (negative or positive) infinity is already handled by the
range checks on the next line, so it’s safe to switch to `isnan()` here.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-11 15:39:47 +00:00
Philip Withnall
5d7f4b8f04 gdatetime: Remove floating point from seconds parsing code
Rather than parsing the seconds in an ISO 8601 date/time using a pair of
floating point numbers (numerator and denominator), use two integers
instead. This avoids issues around floating point precision, and also
makes it easier to check for potential overflow from overlong inputs.

This last point means that the `isfinite()` check can be removed, as it
was covering the case where a NAN was generated, which isn’t now
possible using integer arithmetic.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-11 15:36:56 +00:00
Philip Withnall
819409cf9a Merge branch 'wip/oholy/gio-info-prevent-criticals' into 'master'
gio-tool-info: Prevent criticals if mount options are not available

See merge request GNOME/glib!1794
2020-12-11 13:41:22 +00:00
Ondrej Holy
48a84f6434 gio-tool-info: Prevent criticals if mount options are not available
NULL is valid return value for the g_unix_mount_get_options function
because mount options are currently provided only by libmount implementation.
However, the gio tool passes the returned value to the g_strescape function
without checking, which produces the following critical warning:
GLib-CRITICAL **: 13:47:15.294: g_strescape: assertion 'source != NULL' failed

Let's add the missing check to prevent the critical warnings.
2020-12-11 13:18:27 +00:00
Sebastian Dröge
a28b3c9dd6 Merge branch 'fix-set-contents-typo' into 'master'
gfileutils: Fix typo in docs

See merge request GNOME/glib!1796
2020-12-11 07:27:38 +00:00
Phaedrus Leeds
7ef936f4e3 gfileutils: Fix typo in docs 2020-12-10 21:06:00 -08:00
Florentina Mușat
673f61a763 Update Romanian translation 2020-12-10 16:24:45 +00:00
Yuri Chornoivan
df42290300 Update Ukrainian translation 2020-12-09 15:43:41 +00:00
Sebastian Dröge
68e8fc85b4 Merge branch 'ossfuzz-28473-date-time-iso8601' into 'master'
gdatetime: Disallow NAN as a number of seconds in a GDateTime

See merge request GNOME/glib!1791
2020-12-09 15:12:44 +00:00
Philip Withnall
7e63bc8eb1 Merge branch 'master' into 'master'
array: Avoid sorting 0-sized arrays

Closes #2264

See merge request GNOME/glib!1789
2020-12-09 15:11:57 +00:00
Timm Bäder
c2052a4ada array: Avoid sorting 0-sized arrays
Fixes #2264
2020-12-09 14:52:56 +00:00
Philip Withnall
c3805d74ba gdatetime: Disallow NAN as a number of seconds in a GDateTime
The fiendish thing about NAN is that it never compares TRUE against
anything, so the limit checks `seconds < 0.0 || seconds >= 60.0` were
never triggering.

oss-fuzz#28473

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-09 14:50:02 +00:00
Sebastian Dröge
737a853f8d Merge branch 'wip/pwithnall/2119-osx-app-info' into 'master'
Debuggability improvements in gosxappinfo.m

See merge request GNOME/glib!1787
2020-12-09 12:43:20 +00:00
Sebastian Dröge
e17c5d78fe Merge branch 'ossfuzz-28458-date-overflow' into 'master'
gdate: Validate input as UTF-8 before parsing

See merge request GNOME/glib!1788
2020-12-09 12:41:32 +00:00
Ondrej Holy
aa1e91e838 Merge branch '2098-add-gio-restore-support' into 'master'
Add restore option for trash gio-tool subcommand

Closes #2098

See merge request GNOME/glib!1778
2020-12-09 12:40:59 +00:00
Ondrej Holy
0458ad893a Merge branch '54-add-gio-launch-command' into 'master'
Add gio launch command to execute desktop file

Closes #54

See merge request GNOME/glib!1779
2020-12-09 12:36:41 +00:00
Philip Withnall
b4c2e4d553 gdate: Validate input as UTF-8 before parsing
Dates have to be valid UTF-8.

oss-fuzz#28458

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-09 12:07:41 +00:00
Philip Withnall
a9fc7e5935 gosxappinfo: Add some more precondition checks
These might help catch the problem in #2119 earlier on, and provide more
information about its root cause.

They should not affect behaviour in normal application usage.

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

Helps: #2119
2020-12-09 11:44:37 +00:00
Philip Withnall
2a629b3b4b gosxappinfo: Use strlen() instead of some magic constants
This is equivalent, but makes the code a bit more readable.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-09 11:44:14 +00:00
Philip Withnall
1862a900b1 gosxappinfo: Fix some const-correctness issues
This is technically an API break, as the following assignment may now
raise warnings in user code:
```
gchar *filename = g_osx_app_info_get_filename (app_info);
```

However, from code search it seems like the number of users of that
function is zero.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-09 11:41:38 +00:00
Frederic Martinsons
c3a073e96f Add gio launch command to execute desktop file
This command will try to execute a desktop file, before that
it will load the input as a keyfile for checking its existence
and its validity (as a keyfile).
File arguments are allowed after the desktop file.

Closes #54

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-12-09 08:15:42 +01:00
Philip Withnall
ba62118122 Merge branch 'weak-notify-dispose' into 'master'
Handle the case of g_object_run_dispose() in GBinding

Closes #2265

See merge request GNOME/glib!1786
2020-12-08 19:57:27 +00:00
Sebastian Dröge
e82eb490fe Handle the case of g_object_run_dispose() in GBinding
When this is called on the source or target, the weak notify of the
corresponding object is called without the GWeakRef being cleared.
See https://gitlab.gnome.org/GNOME/glib/-/issues/2266 for that issue.

This means that a strong reference to these zombie objects can be
retrieved from the GWeakRefs and the previous assumption that this can't
happen was wrong. Remove the assertion for that accordingly and handle
this case.

Specifically, all signal handlers and weak notifies of the object are
already gone and must not be disconnected/removed a second time, or
otherwise memory corruption would be caused. Instead just set the
GWeakRef to NULL and handle it otherwise as if the GWeakRef didn't give
a strong reference to begin with.

Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2265
2020-12-08 18:41:27 +02:00
Sebastian Dröge
a2de4b2479 Clarify in g_object_weak_ref() docs that the callback is called during disposing and not finalizing
This especially has the effect that any GWeakRefs to the object will not
necessarily be set to NULL yet if called as part of
g_object_run_dispose() and not as part of g_object_unref().
2020-12-08 18:09:50 +02:00
Philip Withnall
c3f613af0c Merge branch 'coverity-fixes' into 'master'
glocalfile: Add an assertion to help static analysis

See merge request GNOME/glib!1785
2020-12-08 15:56:05 +00:00
Sebastian Dröge
ec330e50cf Merge branch 'more-fuzzing' into 'master'
fuzzing: Add more fuzzing tests for various string parsing functions

See merge request GNOME/glib!1784
2020-12-08 15:10:14 +00:00
Philip Withnall
d5778ec479 gvariant: Clarify operator precedence
This doesn’t change the behaviour of the code, but should squash some
compiler/static analysis warnings about ‘are you sure you got the
precedence right here?’.

Coverity CID: #1159470

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-08 12:17:00 +00:00
Philip Withnall
3a7acd24a9 glocalfile: Add an assertion to help static analysis
Static analysis of the call to `g_dir_new_from_dirp()` is tricky,
because the call is across library boundaries and indirected through a
vfunc map because it’s private to libglib.

Help the static analyser by adding an assertion about the input and
output values for `g_dir_new_from_dirp()`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-08 11:16:43 +00:00
Philip Withnall
105f4a0f39 fuzzing: Add more fuzzing tests for various string parsing functions
There’s no explicit guarantee that any of these functions are safe to
use on untrusted data, but it does no harm to test them.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-08 11:07:43 +00:00
Philip Withnall
b201e028b2 Merge branch 'mcatanzaro/verify-chain-extra-check' into 'master'
gtlsdatabase: remove duplicate precondition check

See merge request GNOME/glib!1783
2020-12-08 09:50:56 +00:00
Michael Catanzaro
855a22e165 gtlsdatabase: remove duplicate precondition check
This check is the same as the check on the line above.
2020-12-07 11:11:37 -06:00
Frederic Martinsons
725984fe8e gio-tool-trash: Add --restore subcommand
It search for attribute trash::orig-path and move the input file to it.
Possibly recreating the directory of orignal path and/or overwritting
the destination.

Closes #2098

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-12-07 17:18:51 +01:00
Frederic Martinsons
105e06cc2e gio-tool-trash: Add --list subcommand
This will print all the files in TrashCan along with their
original location.

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-12-07 17:15:43 +01:00
Philip Withnall
55b4a25eaf 2.67.1
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-07 11:02:56 +00:00
Yuri Chornoivan
1d97e805cb Update Ukrainian translation 2020-12-07 08:53:03 +00:00
Sebastian Dröge
986525f1e9 Merge branch 'ossfuzz-27371-hostname-length' into 'master'
ghostutils: Abandon hostname conversion early if it’s too long

See merge request GNOME/glib!1782
2020-12-07 08:29:31 +00:00
Emmanuel Fleury
bbb9ef19ce Fix signedness warnings in gobject/tests/value.c:test_valuearray_basic()
gobject/tests/value.c: In function ‘test_valuearray_basic’:
gobject/tests/value.c:253:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  253 |   for (i = 0; i < a->n_values - 1; i++)
      |                 ^
gobject/tests/value.c:257:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’}
  257 |   for (i = 0; i < a->n_values; i++)
      |                 ^
2020-12-05 17:11:55 +01:00
Philip Withnall
5e1d368eec Merge branch 'binding-threadsafe-2' into 'master'
Make GBinding thread-safe (alternative approach)

See merge request GNOME/glib!1745
2020-12-04 14:23:10 +00:00
Philip Withnall
95c19181ae guri: Correctly set an error when parsing an invalid hostname
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-04 13:54:27 +00:00
Philip Withnall
1d461bc9f4 ghostutils: Abandon hostname conversion early if it’s too long
The `nameprep()` function in `ghostutils.c` is quite complex, and does a
lot of allocations. This means it can take a long time on long hostnames
(on the order of 10KB long). Hostnames should never be that long,
though, so impose some loose length limits.

oss-fuzz#27371

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-04 13:54:27 +00:00
Philip Withnall
3531239f0e ghostutils: Add missing GIR annotations
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-04 13:16:23 +00:00
Philip Withnall
df7f954dd0 tests: Use g_assert_*() rather than g_assert() in hostutils.c
`g_assert()` is compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-04 12:54:11 +00:00
Philip Withnall
416339305f Merge branch 'coverity-return-values' into 'master'
Minor Coverity fixes

See merge request GNOME/glib!1780
2020-12-03 15:35:36 +00:00
Sebastian Dröge
f83a7d5407 Merge branch 'close-range-enosys' into 'master'
gspawn: Handle ENOSYS from close_range()

See merge request GNOME/glib!1781
2020-12-03 15:29:46 +00:00
Philip Withnall
eba2e7f056 gtestdbus: Retry writes if they fail
It’s unlikely, but shuts up a Coverity warning.

Coverity CID: #1232156

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-03 15:26:03 +00:00
Philip Withnall
24b5d86d4a glocalfile: Check g_stat() return value
There were a couple of places where the return value wasn’t checked, and
hence failure could not be noticed.

Coverity CIDs: #1159435, #1159426

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-03 15:26:03 +00:00
Philip Withnall
23f1a31923 gspawn: Handle ENOSYS from close_range()
It’s possible that GLib will eventually be compiled against a version of
libc which supports `close_range()` (hence `HAVE_CLOSE_RANGE` will be
defined), but then run against an older kernel which doesn’t support it.
In this case, we want to fall back to `fdwalk()`, which should work on
such systems.

This is what cpython does: 3529718925/Python/fileutils.c (L2227)

Spotted by Allison Karlitskaya in !1688.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-12-03 14:30:29 +00:00
Philip Withnall
9a519c8bf0 Merge branch 'selinux-warning' into 'master'
gio: ‘security_context_t’ is deprecated

See merge request GNOME/glib!1776
2020-12-03 13:47:49 +00:00
Daniel Mustieles
48efbc7d6f Updated Spanish translation 2020-12-02 14:16:06 +01:00
Sebastian Dröge
c27f729752 Merge branch 'extend_p_option_for_tests' into 'master'
Extend the usage of -p option for glib test framework

See merge request GNOME/glib!1738
2020-12-02 08:14:12 +00:00