Commit Graph

20965 Commits

Author SHA1 Message Date
Philip Withnall
f4dd85628a gdatetime: Fix error handling in g_date_time_new_week()
It was possible to pass in (for example) an invalid year to
g_date_time_new_week(), which would be passed on to g_date_time_new(),
which would (correctly) return `NULL` — but then
g_date_time_get_week_number() would try to dereference that.

Includes a test case.

oss-fuzz#17648

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-24 18:00:53 +01:00
Philip Withnall
a902addf6d Merge branch 'ossfuzz-12960-markup-attribute-limit' into 'master'
gmarkup: Add a limit on the number of attributes in an element

See merge request GNOME/glib!1116
2019-09-24 13:19:35 +00:00
Sebastian Dröge
4170528bd5 Merge branch '1449-atomic-fallback-safety' into 'master'
gatomic: Reorder memory barriers in fallback atomic operations

Closes #1449

See merge request GNOME/glib!1122
2019-09-24 12:50:14 +00:00
Sebastian Dröge
22aed45408 Merge branch 'docs-heading-typo' into 'master'
docs: Fix typo in GConverter{Input,Output}Stream section titles

See merge request GNOME/glib!1124
2019-09-24 12:40:48 +00:00
Philip Withnall
d0964b72db docs: Fix typo in GConverter{Input,Output}Stream section titles
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-24 12:25:10 +01:00
Nirbheek Chauhan
1f8d3451a4 Merge branch '1565-atomic-signs' into 'master'
Fix sign conversion warnings with g_atomic_int_*() calls in GLib

Closes #1565

See merge request GNOME/glib!1121
2019-09-23 14:20:58 +00:00
Nirbheek Chauhan
e3b87b6ffb Merge branch 'add_g_fsync_function' into 'master'
Add a wrapper for fsync() function

Closes #35

See merge request GNOME/glib!1104
2019-09-23 11:22:25 +00:00
Philip Withnall
9a16f2653b gatomic: Reorder memory barriers in fallback atomic operations
If the compiler doesn’t provide modern (C++11) atomic builtins (which is
now quite unlikely), we implement our own using the `__sync_synchronize()`
memory barrier. As Behdad and others have pointed out, though, the
implementation didn’t follow the same semantics as we use with the C++11
builtins — `__ATOMIC_SEQ_CST`.

Fix the use of memory barriers to provide `__ATOMIC_SEQ_CST` semantics.
In particular, this fixes the following common pattern:
```
GObject *obj = my_object_new ();
g_atomic_pointer_set (&shared_ptr, obj);
```

Previously this would have expanded to:
```
GObject *obj = my_object_new ();
*shared_ptr = obj;
__sync_synchronize ();
```

While the compiler would not have reordered the stores to `obj` and
`shared_ptr` within the code on one thread (due to the dependency
between them), the memory system might have made the write to
`shared_ptr` visible to other threads before the write to `obj` — if
they then dereferenced `shared_ptr` before seeing the write to `obj`,
that would be a bug.

Instead, the expansion is now:
```
GObject *obj = my_object_new ();
__sync_synchronize ();
*shared_ptr = obj;
```

This ensures that the write to `obj` is visible to all threads before
any write to `shared_ptr` is visible to any threads. For completeness,
`__sync_synchronize()` is augmented with a compiler barrier to ensure
that no loads/stores can be reordered locally before or after it.

Tested by disabling the C++11 atomic implementation and running:
```
meson test --repeat 1000 atomic atomic-test
```

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1449
2019-09-21 16:16:21 +02:00
Philip Withnall
ec848cb174 tests: Use g_assert_*() in atomic tests rather than g_assert()
`g_assert_*()` provide more useful failure messages, and aren’t compiled
out when building with `G_DISABLE_ASSERT`, unlike `g_assert()`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-21 10:54:52 +02:00
Philip Withnall
55f9c6d2f4 gatomic: Add various casts to use of g_atomic_*()s to fix warnings
When compiling GLib with `-Wsign-conversion`, we get various warnings
about the atomic calls. A lot of these were fixed by
3ad375a629, but some remain. Fix them by
adding appropriate casts at the call sites.

Note that `g_atomic_int_{and,or,xor}()` actually all operate on `guint`s
rather than `gint`s (which is what the rest of the `g_atomic_int_*()`
functions operate on). I can’t find any written reasoning for this, but
assume that it’s because signedness is irrelevant when you’re using an
integer as a bit field. It’s unfortunate that they’re named a
`g_atomic_int_*()` rather than `g_atomic_uint_*()` functions.

Tested by compiling GLib as:
```
CFLAGS=-Wsign-conversion jhbuild make -ac |& grep atomic
```

I’m not going to add `-Wsign-conversion` to the set of default warnings
for building GLib, because it mostly produces false positives throughout
the rest of GLib.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1565
2019-09-21 10:48:23 +02:00
Philip Withnall
3ad375a629 Merge branch '1843-tsan-atomic-clang-fix' into 'master'
gatomic: Fix false positive with Clang+TSAN

Closes #1843

See merge request GNOME/glib!1006
2019-09-21 07:56:28 +00:00
Sebastian Schwarz
2d37239510 gspawn: Optimize fd closing on AIX and BSDs
Instead of calling close or fcntl on all possible file descriptors,
which is slow on systems with very high limit or even no limit on open
file descriptors, we can use closefrom or fcntl with F_CLOSEM to close
all unwanted file descriptors with a single system call.

This change only improves the performance when GSpawnChildSetupFunc is
NULL because there are applications known to abuse GSpawnChildSetupFunc
to unset FD_CLOEXEC on file descriptors. Since the change mentioned
above requires closing file descriptors directly, it cannot be used when
the caller may want to keep some of them open.

This patch was written by Sebastian Schwarz <seschwar@gmail.com> and
uploaded to https://gitlab.gnome.org/GNOME/glib/merge_requests/574.
It was later modified by Ting-Wei Lan <lantw@src.gnome.org> to address
code review issues.

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1638
2019-09-20 22:28:29 +08:00
Philip Withnall
c8bad68884 Merge branch 'utils-doc-annotations' into 'master'
Annotate the return value of various utility functions

See merge request GNOME/glib!1119
2019-09-20 12:13:00 +00:00
Emmanuele Bassi
273049aea7 Annotate the return value of various utility functions
While the introspection scanner can glean the transfer rule for the
return values by looking at their constness, adding an explicit
annotation has the advantage of gtk-doc writing out the transfer rule as
an additional bit of documentation, making the life of the documentation
reader easier.
2019-09-20 12:35:24 +01:00
Sebastian Dröge
744f5c42da Merge branch '767-signal-class-refs' into 'master'
gsignal: Document class init before signals can be looked up

Closes #767

See merge request GNOME/glib!1118
2019-09-20 11:14:56 +00:00
Philip Withnall
66a5704bdf Merge branch 'gobject-tutorial-no-priv' into 'master'
docs: Remove priv pointers from the tutorial example

See merge request GNOME/glib!1020
2019-09-20 09:54:01 +00:00
Emmanuele Bassi
b96e318f3a docs: Remove priv pointers from the tutorial example
We define `ViewerFile` as a final type with fields directly in the
instance structure. This means we don't have a `priv` pointer to
dereference.
2019-09-20 11:38:47 +02:00
Philip Withnall
9ca97b8b0b gsignal: Document class init before signals can be looked up
Fixes: #767

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-20 11:23:08 +02:00
Philip Withnall
c4ec302932 Merge branch 'ossfuzz-16103-ordinal-dates' into 'master'
gdatetime: Fix error handling in g_date_time_new_ordinal()

See merge request GNOME/glib!1115
2019-09-19 21:18:57 +00:00
Philip Withnall
57fc0be857 gmarkup: Add a limit on the number of attributes in an element
While the XML specification doesn’t prescribe a limit, no reasonable bit
of XML is going to have more than 1000 attributes in a single XML
element.

Adding a limit reduces the changes of a runaway allocation loop caused
by dodgy input.

oss-fuzz#12960

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-18 17:06:20 +01:00
Philip Withnall
5c6030ef8d gdatetime: Fix error handling in g_date_time_new_ordinal()
It was possible to pass in (for example) an invalid hour to
g_date_time_new_ordinal(), which would be passed on to
g_date_time_new(), which would (correctly) return `NULL` — but then
g_date_time_new_ordinal() would try to dereference that.

Includes some test cases.

oss-fuzz#16103
oss-fuzz#17183

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-18 12:44:28 +01:00
Todd Goyen
3636bb5fe1 Add a wrapper for fsync() function
Closes issue #35
2019-09-18 10:47:23 +02:00
Emmanuel Fleury
2f9c9e2c5a Switching from C gnu89 to C gnu99 standard 2019-09-17 19:48:56 +02:00
Emmanuel Fleury
59882fb9e1 Fixing inlining bug in gnulib/xsize.h
See: https://lists.gnu.org/archive/html/bug-gettext/2013-01/msg00011.html

Courtesy to chrisawi (Chris William)
2019-09-17 19:48:56 +02:00
Emmanuele Bassi
96c25ceba6 Merge branch 'since-2-64' into 'master'
Add version macros for GLib 2.64

See merge request GNOME/glib!1112
2019-09-17 16:06:33 +00:00
Philip Withnall
3b1e301ab5 gversionmacros: Add version macros for GLib 2.64
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-17 12:24:16 +01:00
Philip Withnall
bbccd2c1d7 build: Post-release version bump to 2.63.0
Ready for the new unstable release series.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-17 12:23:06 +01:00
Sebastian Dröge
cf25d9a2ec Merge branch 'wip/oholy/gio-remove-completion' into 'master'
gio: Add missing "gio remove" option to bash completion script

See merge request GNOME/glib!1110
2019-09-17 10:06:49 +00:00
Sebastian Dröge
1963821a57 Merge branch 'g_utf8_get_char_validated_wrong_return_on_null_byte' into 'master'
Add a missing check to g_utf8_get_char_validated()

Closes #1052

See merge request GNOME/glib!967
2019-09-17 10:01:58 +00:00
Sebastian Dröge
96a1e35e62 Merge branch 'system-alloc' into 'master'
gmem: clarify that g_malloc always uses the system allocator

See merge request GNOME/glib!1099
2019-09-16 13:50:22 +00:00
Daniel P. Berrangé
1f24b36607 gmem: clarify that g_malloc always uses the system allocator
Support for custom allocators was dropped in

  commit 3be6ed60aa
  Author: Alexander Larsson <alexl@redhat.com>
  Date:   Sat Jun 27 18:38:42 2015 +0200

    Deprecate and drop support for memory vtables

The introductory doc text for the gmem APIs still warns against mixing
malloc/free with g_malloc/g_free. Clarify upfront in the docs that these
two sets of APIs are now guaranteed to use the same memory allocator &
can thus their usage can be freely mixed.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-09-16 14:03:07 +01:00
Philip Withnall
d14f64d7e1 Merge branch 'instead' into 'master'
doc: fix typo in gio/gsettings.c

See merge request GNOME/glib!1109
2019-09-16 11:19:00 +00:00
Ondrej Holy
84c8899fca gio: Add missing "gio remove" option to bash completion script
Bash completion	script allows to complete various options, but "gio remove"
is missing. Let's add this missing option.
2019-09-16 11:19:50 +02:00
Rico Tzschichholz
ed2ceae9f0 gmarkup: Fix parameter annotations for g_markup_parse_context_get_position 2019-09-15 17:35:04 +02:00
Марко Костић
cbd3dfe381 Update Serbian translation
(cherry picked from commit c8abd972d7)
2019-09-15 09:02:22 +00:00
Egmont Koblinger
8f30e6c3bb doc: fix typo in gio/gsettings.c 2019-09-14 23:11:57 +02:00
Emmanuel Fleury
568720006c Add a missing check to g_utf8_get_char_validated()
g_utf8_get_char_validated() was not exactly matching its
documentation. The function was not checking if the sequence of
unicode characters was free of null bytes before performing a more
in-depth validation.

Fix issue #1052
2019-09-14 18:01:22 +02:00
Philip Withnall
86c282cd78 Merge branch 'iov-max' into 'master'
Define G_IOV_MAX to 512 on macOS/iOS

See merge request GNOME/glib!1095
2019-09-13 13:37:25 +00:00
Nirbheek Chauhan
b01bbe6536 Merge branch '1767-scan-build-fixes' into 'master'
Various small scan-build fixes

See merge request GNOME/glib!1088
2019-09-13 12:37:37 +00:00
Sebastian Dröge
6d4738ed22 Merge branch '1875-xdgmimecache-robustness' into 'master'
xdgmime: Prevent infinite loops from badly-formed MIME registrations

Closes #1875

See merge request GNOME/glib!1085
2019-09-13 11:42:55 +00:00
Philip Withnall
adf96047f4 xdgmime: Prevent infinite loops from badly-formed MIME registrations
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1875
2019-09-13 12:13:49 +01:00
Philip Withnall
93e54d505a Merge branch 'clang-declare-type-unused' into 'master'
gtype: mark the inline functions in G_DECLARE_*_TYPE() as UNUSED

See merge request GNOME/glib!1062
2019-09-13 10:59:29 +00:00
Xavier Claessens
a6ef0debab Merge branch 'doc-win' into 'master'
Fix doc build on Windows

Closes #1888

See merge request GNOME/glib!1092
2019-09-11 17:30:18 +00:00
Sebastian Dröge
81f614533d Define G_IOV_MAX to 512 on macOS/iOS
For macOS/iOS, UIO_MAXIOV is documented in writev(2), but <sys/uio.h> only
declares it if defined(KERNEL)

Inspired by a GStreamer MR by Jim Mason
https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/277
2019-09-10 10:16:03 +03:00
Nirbheek Chauhan
e589477202 Merge branch 'root-test-fix' into 'master'
tests: Fix skipping mkdir-with-parents-permission test

See merge request GNOME/glib!1080
2019-09-10 06:42:36 +00:00
Nirbheek Chauhan
3d7f9205d7 Merge branch 'fix_a_misunderstanding_in_gtypeaddinterface' into 'master'
docs: fix a misunderstanding in g_type_add_interface_*

Closes #259

See merge request GNOME/glib!1077
2019-09-10 04:50:29 +00:00
Xavier Claessens
65f64f0988 Fix doc build on Windows
This is a work around for this Meson bug:
https://github.com/mesonbuild/meson/issues/5893

Closes: #1888
2019-09-09 08:51:46 -04:00
A S Alam
8f2164bb88 Update Punjabi translation
(cherry picked from commit e75a6b546f)
2019-09-09 05:41:43 +00:00
Sebastian Dröge
f944049869 Merge branch 'remove-gmodule-dyld' into 'master'
gmodule: remove macOS dyld implementation

See merge request GNOME/glib!1093
2019-09-07 16:16:20 +00:00
Tom Schoonjans
3daa3ac835 gmodule: remove macOS dyld implementation
It did not work for dylibs, was full of ancient, deprecated code,
and was not actually used anyway.
2019-09-07 16:41:34 +01:00