Commit Graph

6066 Commits

Author SHA1 Message Date
Tomasz Miąsko
6d108587a4 gvariant-core: Use gatomicrefcount for GVariant reference count 2018-11-06 14:39:19 +01:00
Philip Withnall
409ff69bd1 gvariant: Re-use g_variant_serialised_check() to check alignment
Rather than duplicating the alignment checks when constructing a new
GVariant, re-use the alignment checks from GVariantSerialised. This
ensures that the same checks are done everywhere in the GVariant code.

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

https://gitlab.gnome.org/GNOME/glib/issues/1342
2018-11-06 12:49:25 +00:00
Philip Withnall
7b0f2e0e34 gvariant: Fix some GIR annotations on internal functions
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-11-06 11:50:20 +00:00
Philip Withnall
0f2a6c61c9 gvariant: Realign data on construction if it’s not properly aligned
Otherwise the GVariant would later fail internal alignment checks,
aborting the program.

If unaligned data is provided to (for example)
g_variant_new_from_data(), it will copy the data into a new aligned
allocation. This is slow, but better than crashing. If callers want
better performance, they should provide aligned data in their call, and
it will not be copied or reallocated.

Includes a unit test.

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

https://gitlab.gnome.org/GNOME/glib/issues/1342
2018-11-06 11:50:20 +00:00
Marco Trevisan (Treviño)
cfd164980d gbookmarkfile: remove trailing spaces 2018-11-05 17:15:42 -06:00
Marco Trevisan (Treviño)
821d28024b bookmarkfile: Don't move an item if the uri has not changed
This was causing a crash, because we were first removing an item, freeing
both the instance itself and the key, and then trying to reuse those.

So, in this case, instead of reassigning an item, we can just return TRUE
as we have already the item at the right place, while it's not needed to
update the modified timestamp, since no modification happened in reality.

Fixes #1588
2018-11-05 17:15:32 -06:00
Marco Trevisan (Treviño)
94edafb5fa bookmarkfile: test that moving to the same name works
Verify that we can move a bookmark item to the same name, but actually this
causes a crash right now.
2018-11-05 17:06:52 -06:00
Tomasz Miąsko
68e78c6eb2 tests: Fix data races in gwakeuptest.c 2018-11-04 17:28:58 +01:00
Philip Withnall
73a982fa91 Merge branch 'wip/sadiq/likely' into 'master'
gmacros: Fix G_[UN]LIKELY to not mask -Wparentheses

See merge request GNOME/glib!372
2018-11-02 20:45:38 +00:00
Philip Withnall
74d2a8e500 Merge branch 'test-timeout' into 'master'
meson: Increase test timeouts

See merge request GNOME/glib!407
2018-11-02 11:02:32 +00:00
Philip Withnall
8f115b63b1 Merge branch 'atomic-ref-count' into 'master'
gvarianttypeinfo: Consistently use atomics to access ref_count

See merge request GNOME/glib!444
2018-11-02 10:29:48 +00:00
Tomasz Miąsko
aed3c0083b gtestutils: Make test_rand_* thread-safe within a single test case
Synchronize access to random number generator `test_run_rand` with
a lock to ensure that `g_test_rand_*` family of functions is
thread-safe.

The reseeding taking place between test case runs is intentionally left
unsynchronized. It is an error to continue using random number generator
after test case has already finished running. Lack of synchronization
here will make such erroneous use readily apparent with thread
sanitizer.
2018-11-02 08:29:08 +01:00
Tomasz Miąsko
03518e576e gvarianttypeinfo: Consistently use atomics to access ref_count 2018-11-01 21:55:07 +01:00
Simon McVittie
03413d5a87 meson: Mark gdatetime test as slow
This test isn't inherently slow, but it produces so much output that
it can take a minute or more on hardware with weak I/O performance.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-01 19:13:21 +00:00
Simon McVittie
13e206aaeb meson: Centralize test timeout values
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-01 19:13:21 +00:00
Philip Withnall
664fb6303b Revert "gdatetime: Enable compile time check of g_date_time_format() format"
This reverts commits:
 • 9ddcc79502ae02adc3c3

g_date_time_format() supports a few non-standard format placeholders:
 • %:z
 • %::z
 • %:::z

These are all gnulib strtime() extensions, and hence are not recognised
by the compiler when the function is annotated with G_GNUC_STRFTIME.
However, this wasn’t noticed when we originally merged this change
because the errors were disabled in the tests which covered those
placeholders.
2018-11-01 16:12:32 +00:00
Matthias Clasen
9ddcc79502 Remove the G_GNUC_STRFTIME format check
This does not work, since g_date_time_format() supports
non-standard extensions such as %:::z, and this has
broken several consumers which use format errors, such
as ostree.
2018-11-01 12:00:58 -04:00
Philip Withnall
4f81c9eb97 Merge branch 'gdate-timezone' into 'master'
gdatetime: Fix formatting of time zones offsets in range -01:00 to +00:00

See merge request GNOME/glib!435
2018-10-31 22:35:00 +00:00
Philip Withnall
e7738e46a8 Merge branch 'mr/issue-1575' into 'master'
Enable compile time check of g_date_time_format() format

See merge request GNOME/glib!412
2018-10-31 22:23:50 +00:00
Christophe Fergeau
bd6d603398 test-gvariant: Add missing spaces before parens
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-31 18:44:21 +01:00
Christophe Fergeau
38d48b818a test-gvariant: Add and use assert_cmpstrv helper
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-31 18:44:21 +01:00
Christophe Fergeau
422d83cbaa test-gvariant: Remove some hardcoded strings
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-31 18:43:19 +01:00
Christophe Fergeau
572f78b649 test-gvariant: Use g_assert_* rather than g_assert()
This is desirable both to get more detailed failure messages; and
because g_assert() is compiled out when compiling with G_DISABLE_ASSERT,
which renders the tests useless.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-31 18:43:17 +01:00
Christophe Fergeau
e6e04d3b15 test-gvariant: Use gsize for loop indices
gint is not the best type when looping from 0 to N > 0, which usually is
the case in loops.  There are a few cases in this patch where guint is
used rather than gsize, this is when the index is used in a printf-like
function as this makes the format string easier to read

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-31 18:41:00 +01:00
Christophe Fergeau
b0a013e20e gvariant: Handle ^ay, ^&ay, ^aay, ^a&ay in g_variant_valist_free_nnp
g_variant_valist_free_nnp does not take into account ^*ay, which causes
crash when trying to use these types together with
g_variant_iter_loop().
2018-10-31 18:38:11 +01:00
Tomasz Miąsko
54c394a73f gdatetime: Fix formatting of time zones offsets in range -01:00 to +00:00
Formatting code for `%z` specifier incorrectly assumed that sign of
offset from UTC can be recovered from the number of hours alone, which
is not true for offsets between -01:00 and +00:00.

Extract and format sign separately to avoid the problem.

Issue #1337.
2018-10-31 15:02:22 +01:00
Christian Persch
ae02adc3c3 gdatetime: Enable compile time check of g_date_time_format() format
By annotating it with G_GNUC_STRFTIME.

https://gitlab.gnome.org/GNOME/glib/issues/1575
2018-10-31 11:50:07 +01:00
Christian Persch
d62a07831c gmacros: Add G_GNUC_STRFTIME macro
Analogous to G_GNUC_PRINTF and G_GNUC_SCANF, to annotate
functions similar to strftime.

https://gitlab.gnome.org/GNOME/glib/issues/1575
2018-10-31 11:50:07 +01:00
Christophe Fergeau
7d1b94d71a test-gvariant: Add test for ^ay, ^&ay, ^aay, ^a&ay
This will exhibit bugs in g_variant_valist_free_nnp() as these types are
not properly handled.
2018-10-30 21:04:08 +01:00
Philip Withnall
ff8b731639 gkeyfile: Fix parsing of new lines in comments
Previously, the code which parsed comments in key files would append a
line break to the comment where there was none before; this was part of
the code for handling re-inserting line breaks into multi-line comments
after removing the ‘#’ prefix. Now, we don’t add a terminal line break.

This was slightly icky to implement because parse_value_as_comment() is
called once for each line of a multi-line comment.

This expands the existing test case to cover a single line comment, and
also fixes the documentation to correctly state that the leading ‘#’
*is* removed and mention the new line break behaviour.

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

https://gitlab.gnome.org/GNOME/glib/issues/107
2018-10-30 11:55:30 +00:00
Philip Withnall
09799a8b25 Merge branch 'meson-test-cleanup' into 'master'
Meson: Cleanup a FIXME now that we have dict addition

See merge request GNOME/glib!418
2018-10-30 11:33:20 +00:00
Tomasz Miąsko
a8fd91aae5 gdate: Reinitialize locale information in g_date_prepare_to_parse.
When g_date_set_parse was used with more than one locale it could
incorrectly retain information from previous one. Reinitialize all
locale specific data inside g_date_prepare_to_parse to avoid the issue.
2018-10-30 00:24:40 +01:00
Philip Withnall
c1b3177461 Merge branch '827-main-context-docs' into 'master'
gmain: Clarify that g_source_set_callback() is safe on attached sources

Closes #827

See merge request GNOME/glib!426
2018-10-29 22:32:51 +00:00
Philip Withnall
58b96353f4 Merge branch 'issue-1562' into 'master'
tests: Update month name check for Lithuanian locale

Closes #1562

See merge request GNOME/glib!373
2018-10-29 22:22:27 +00:00
Philip Withnall
bfe5906b40 gmain: Clarify that g_source_set_callback() is safe on attached sources
g_source_set_callback() and g_source_set_callback_indirect() are both
safe to call zero or more times on attached sources. The change in
callback will take effect the next time the source is dispatched, after
the set_callback() call returns (it could block due to locking).

https://gitlab.gnome.org/GNOME/glib/issues/827
2018-10-29 22:10:33 +00:00
Philip Withnall
c2501a81f8 Merge branch 'ossfuzz-9672-markup-overflow' into 'master'
GMarkup buffer overflow fixes for error handling, round 2

See merge request GNOME/glib!422
2018-10-29 22:03:05 +00:00
Ting-Wei Lan
295964a380 gutils: Check whether getauxval function exists
FreeBSD 12 adds a new header, sys/auxv.h, to declare a function, elf_aux_info,
for public use, which was considered an internal function in previous releases.
This new function provides similar functionality with glibc getauxval, which is
also declared in the same header, but their interfaces are not compatible. Since
the only usage of sys/auxv.h is in g_check_setuid and FreeBSD already has
issetugid to provide the required functionality, we fixes the compilation error
by adding a check for getauxval function to prevent g_check_setuid from calling
getauxval when sys/auxv.h is found but getauxval is not available.

https://reviews.freebsd.org/D12743
https://reviews.freebsd.org/rS324815
2018-10-29 14:57:24 +00:00
Philip Withnall
1a7f07f6bf tests: Rework markup parsing test to not stop on first failure
Previously, the markup parsing test would load a given markup file and
try to parse it several ways. It would return as soon as one of the
attempts failed — meaning that bugs only seen with non-nul-terminated,
or differently chunked, parse runs could never be caught.

Rework the tests so that all markup files are tested all ways, and we
assert that all ways of parsing them give the same result.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-26 23:23:00 +13:00
Philip Withnall
2187b1bec4 gmarkup: Fix validation of element names
Previously, the element name validation only happened if a start_element
callback was specified on the context. Element name validation should be
unconditional.

This was causing test-5.gmarkup to fail when run against the improved
tests in the following commit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-26 23:23:00 +13:00
Philip Withnall
3a961236dd gmarkup: Avoid reading off the end of a buffer when non-nul-terminated
When extracting a UTF-8 character to put in an error message on parse
failure, pass the remaining buffer length to utf8_str() to avoid it
running off the end of the input buffer. It previously assumed that the
buffer was nul-terminated, which was the case in all the tests until
now.

A following commit will add test coverage for this.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-26 23:08:43 +13:00
Philip Withnall
f502141f98 tests: Run GMarkup tests with and without nul-termination
When using GMarkup to parse a string, the string can be provided with an
explicit length specified, or with no length and a nul terminator
instead. Run all the GMarkup tests both ways, to catch problems with
length checks, or with nul terminator checks.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-26 22:57:07 +13:00
Philip Withnall
d6f2462ee0 tests: Add another GMarkup test from oss-fuzz
This doesn’t trigger any new failures, but is distinct from other tests
we have, so would be good to retain.

Related to commit cec7170540.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-26 22:57:07 +13:00
Xavier Claessens
aff686a2fb Meson: Cleanup a FIXME now that we have dict addition 2018-10-25 10:50:10 -04:00
Philip Withnall
25b7716e0d Merge branch 'nirbheek/macos-library-versions' into 'master'
meson: Add macOS libtool versioning for ABI compatibility

See merge request GNOME/glib!282
2018-10-24 00:00:35 +00:00
Ondrej Holy
85de7749c4 Merge branch 'dirname-of-root-docs' into 'master'
gfileutils: Add examples to g_path_get_dirname() documentation

See merge request GNOME/glib!410
2018-10-23 06:49:57 +00:00
Philip Withnall
1c421b0158 glib: Port various callers to use g_utf8_validate_len()
These were callers which explicitly specified the string length to
g_utf8_validate(), when it couldn’t be negative, and hence should be
able to unconditionally benefit from the increased string handling
length.

At least one call site would have previously silently changed behaviour
if called with strings longer than G_MAXSSIZE in length.

Another call site was passing strlen(string) to g_utf8_validate(), which
seems pointless: just pass -1 instead, and let g_utf8_validate()
calculate the string length. Its behaviour on embedded nul bytes
wouldn’t change, as strlen() stops at the first one.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
7a4025cac1 gutf8: Add a g_utf8_validate_len() function
This is a variant of g_utf8_validate() which requires the length to be
specified, thereby allowing string lengths up to G_MAXSIZE rather than
just G_MAXSSIZE.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
5f3b393662 gvariant: Clarify internal documentation about GVariant type strings
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
f148687b02 gvariant: Limit GVariant strings to G_MAXSSIZE
When validating a string to see if it’s valid UTF-8, we pass a gsize to
g_utf8_validate(), which only takes a gssize. For large gsize values,
this will result in the gssize actually being negative, which will
change g_utf8_validate()’s behaviour to stop at the first nul byte. That
would allow subsequent nul bytes through the string validator, against
its documented behaviour.

Add a test case.

oss-fuzz#10319

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
7eedcd76f7 gvariant: Check tuple offsets against serialised data length
As with the previous commit, when getting a child from a serialised
tuple, check its offset against the length of the serialised data of the
tuple (excluding the length of the offset table). The offset was already
checked against the length of the entire serialised tuple (including the
offset table) — but a child should not be able to start inside the
offset table.

A test is included.

oss-fuzz#9803

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
5e0b12df1a gvariant: Check array offsets against serialised data length
When getting a child from a serialised variable array, check its offset
against the length of the serialised data of the array (excluding the
length of the offset table). The offset was already checked against the
length of the entire serialised array (including the offset table) — but a
child should not be able to start inside the offset table.

A test is included.

oss-fuzz#9803

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
7c4e6e9fbe gvarianttype: Impose a recursion limit of 128 on variant types
Previously, GVariant has allowed ‘arbitrary’ recursion on GVariantTypes,
but this isn’t really feasible. We have to deal with GVariants from
untrusted sources, and the nature of GVariantType means that another
level of recursion (and hence, for example, another stack frame in your
application) can be added with a single byte in a variant type signature
in the input. This gives malicious input sources far too much leverage
to cause deep stack recursion or massive memory allocations which can
DoS an application.

Limit recursion to 128 levels (which should be more than enough for
anyone™), document it and add a test. This is, handily, also the limit
of 64 applied by the D-Bus specification (§(Valid Signatures)), plus a
bit to allow wrapping of D-Bus messages in additional layers of
variants.

oss-fuzz#9857

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
eb7c9adc3b gvariant: Fix checking arithmetic for tuple element ends
When checking whether a serialised GVariant tuple is in normal form,
it’s possible for `offset_ptr -= offset_size` to underflow and wrap
around, resulting in gvs_read_unaligned_le() reading memory outside the
serialised GVariant bounds.

See §(Tuples) in gvariant-serialiser.c for the documentation on how
tuples are serialised. Briefly, all variable-length elements in the
tuple have an offset to their end stored in an array of offsets at the
end of the tuple. The width of each offset is in offset_size. offset_ptr
is added to the start of the serialised tuple to get the offset which is
currently being examined. The offset array is in reverse order compared
to the tuple elements, hence the subtraction.

The bug can be triggered if a tuple contains a load of variable-length
elements, each of whose length is actually zero (i.e. empty arrays).

Includes a unit test.

oss-fuzz#9801

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 17:01:51 +13:00
Philip Withnall
ec5d6ab63d gfileutils: Add examples to g_path_get_dirname() documentation
See https://gitlab.gnome.org/GNOME/glib/merge_requests/326.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-23 14:38:13 +13:00
Philip Withnall
da512adc34 Merge branch 'stap-pass-cflags' into 'master'
build-sys: Pass CFLAGS to $(DTRACE)

See merge request GNOME/glib!403
2018-10-22 22:39:59 +00:00
Nirbheek Chauhan
8b3590c231 meson: Add macOS libtool versioning for ABI compatibility
With this, the compatibility version and current version values in macOS
and iOS dylibs will match the values set by Autotools.

See: https://github.com/mesonbuild/meson/issues/1451
2018-10-22 06:51:32 +05:30
Simon McVittie
442b54f00c meson: Mark 1bit-emufutex test as slow
Emulated futexes are slower than real ones; if they were not, there
would be no point in using the real futexes. On some machines they
are sufficiently slow to cause test timeouts.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-19 09:20:25 +01:00
Colin Walters
d7233ef81e build-sys: Pass CFLAGS to $(DTRACE)
Fedora is using https://fedoraproject.org/wiki/Changes/Annobin
to try to ensure that all objects are built with hardening flags.
Pass down `CFLAGS` to ensure the SystemTap objects use them.
2018-10-15 21:50:31 +00:00
Fabrice Fontaine
09c149453a grefcount: add missing gatomic.h
Without gatomic.h, build fails on:
In file included from garcbox.c:24:0:
garcbox.c: In function ‘g_atomic_rc_box_acquire’:
grefcount.h:101:13: error: implicit declaration of function ‘g_atomic_int_get’; did you mean ‘__atomic_store’? [-Werror=implicit-function-declaration]
     (void) (g_atomic_int_get (rc) == G_MAXINT ? 0 : g_atomic_int_inc ((rc))); \
             ^
garcbox.c:292:3: note: in expansion of macro ‘g_atomic_ref_count_inc’
   g_atomic_ref_count_inc (&real_box->ref_count);

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2018-10-13 23:10:33 +02:00
Hans Petter Jansson
d3074a748f ghash: Fix out-of-range use of signed integer
We were mistakenly shifting a signed int literal by up to 31 places.
Specify unsigned int instead.

Closes #1570
2018-10-12 13:09:39 +02:00
Philip Withnall
efda2be302 Merge branch 'ghash-hpj-2018' into 'master'
GHashTable improvements

See merge request GNOME/glib!208
2018-10-10 23:01:51 +00:00
Philip Withnall
0b45ddc556 Merge branch 'poolname' into 'master'
gthreadpool: Include prgname in thread name

See merge request GNOME/glib!374
2018-10-10 22:45:08 +00:00
Vincent Whitchurch
c50bdf07e8 gthreadpool: Include prgname in thread name
All pool threads are named "pool" and this a bit annoying when looking
at system-wide traces or statistics for a system where several
applications use thread pools.  Include the prgname in the thread names
to get a better default name.  The total length including the "pool-"
prefix is limited to 16 bytes in order for it to work on all systems.

Change-Id: I473a9f534c4630f3e81da72ff96d8f593c60efac
2018-10-10 10:57:39 +02:00
Mohammed Sadiq
0e7ebf794f gmacros: Fix G_[UN]LIKELY to not mask -Wparentheses
A double paren forces the compiler to assume that the
statement is right.  That may not be the case.

This is essentially reverting b44fba25fb.
See https://bugzilla.gnome.org/show_bug.cgi?id=760215.

It's more morth to allow find common mistakes (= instead of ==
in conditionals) than masking them to make some rarely used
code work.
2018-10-09 06:44:14 +05:30
Emmanuele Bassi
4d215e006e tests: Update month name check for Lithuanian locale
Update the abbreviated month name in the test to match the GNU libc
translation, coming from CLDR.

Fixes #1562
2018-10-04 14:43:53 +02:00
Hans Petter Jansson
eed0f182fd tests: Remove assertion that unused buckets should have NULL key/value
We still clear the key/value on removal, but since we're growing the
arrays with realloc() now, we can't guarantee that incoming memory is
cleared. There's no reason it should be either, since we check the
hashes array (which is always in a defined state) before accessing the
other arrays.
2018-10-03 22:14:38 +02:00
Hans Petter Jansson
9986395638 ghash: Use realloc in place of alloc for key/value
Minor simplification resulting in the removal of redundant alloc wrappers.
2018-10-03 22:14:38 +02:00
Hans Petter Jansson
194eef5f17 ghash: Be less eager to opportunistically grow the table on cleanup
When g_hash_table_resize() gets called, we clear out tombstones and grow
the table at the same time if needed. However, the threshold was set too
low, so we'd grow if the load was greater than .5 after subtracting
tombstones. Increase this threshold to ~.75.
2018-10-03 22:14:38 +02:00
Hans Petter Jansson
7eaf018b29 ghash: Significantly reduce peak memory use
When resizing, we were keeping both the old and new hash, key and value
arrays around while we reinserted entries, resulting in a peak memory
overhead of 50%. Using a temporary bookkeeping array with one bit per
entry we can now grow and shrink the main arrays using realloc() and an
eviction scheme, reducing the overhead to .625% (assuming 64-bit keys and
values). Tests show the CPU overhead is negligible.
2018-10-03 22:14:32 +02:00
Hans Petter Jansson
dc983d74cc ghash: Use less memory when storing ints on 64-bit platforms
If int is smaller than void * on our arch, we start out with
int-sized keys and values and resize to pointer-sized entries as
needed. This saves a good amount of memory when the HT is being
used with e.g. GUINT_TO_POINTER().
2018-10-03 22:11:07 +02:00
Philip Withnall
96c653265f gmessages: Reformat g_return_*if_fail() macros to fix whitespace
I’m fed up of trying to read these and having my head done in by mixed
tabs and spaces.

This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-10-03 14:45:12 +01:00
Philip Withnall
7b5756577f Merge branch 'fix-leaking-g_get_language_names_with_category' into 'master'
gcharset: fix leaking g_get_language_names_with_category

See merge request GNOME/glib!338
2018-10-02 10:42:14 +00:00
Philip Withnall
32e049b761 Merge branch 'win32-gstat-for-ucrt' into 'master'
W32: gstat fixes for ucrt

Closes #1452

See merge request GNOME/glib!257
2018-10-02 08:55:45 +00:00
Philip Withnall
846a61457a Merge branch 'wjt/g_desktop_app_info_get_string_list' into 'master'
Add g_desktop_app_info_get_string_list(); fix g_key_file_free()

See merge request GNOME/glib!339
2018-10-01 19:21:05 +00:00
Ryan Schmidt
a187c89002 Fix build failure on systems without spawn.h 2018-09-28 23:50:40 -05:00
Xavier Claessens
6e0a03ee07 Merge branch '1536-link-whole' into 'master'
Meson: Fix static linking of convenience libraries

Closes #1536

See merge request GNOME/glib!357
2018-09-28 14:54:40 +00:00
Simon McVittie
62af03bda8 Meson: Extract objects from convenience libraries to link them
This avoids the convenience library being treated as though it was
an installed static library (objects not included in the dependent
static library, and convenience library being listed in the pkg-config
metadata), both of which would make static linking impossible.
This is a workaround for meson not having
https://github.com/mesonbuild/meson/pull/3939 merged yet.

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1536
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-09-28 15:15:48 +01:00
Philip Withnall
c824ffd377 Merge branch 'wip/rishi/docs-garray' into 'master'
Documentation tweaks for g_array_free

See merge request GNOME/glib!348
2018-09-28 13:06:04 +00:00
Xavier Claessens
88a1188fc1 Merge branch 'speling' into 'master'
Fix spelling mistakes detected by Debian's Lintian tool

See merge request GNOME/glib!354
2018-09-25 18:16:52 +00:00
Xavier Claessens
af9e67c776 Merge branch '1544-gtester-report' into 'master'
Generate gtester-report from .in file

Closes #1544

See merge request GNOME/glib!352
2018-09-25 18:00:13 +00:00
Simon McVittie
8346017b17 Generate gtester-report from .in file
Previously, it was installed unmodified by the Meson build system.

We don't need to define @bindir@, because gtester-report never
actually referred to it. We also don't need a definition of
GTESTER_REPORT for use by GLib itself, because its last use was removed
in 2013 (https://bugzilla.gnome.org/show_bug.cgi?id=709995).

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1544
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-09-25 17:34:57 +01:00
Simon McVittie
59bede934c Spelling: Fix a common en_FR spelling of "information"
Detected by Debian's Lintian tool.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-09-25 14:35:11 +01:00
Simon McVittie
cbc7fbbf7d meson: Run build-time tests with --tap where supported
This makes it easier to debug test failures, by ensuring that g_debug()
and g_test_message() are printed as TAP diagnostics.

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/1528
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-09-24 23:37:12 +01:00
Debarshi Ray
0a8f3698a0 docs: Simplify the text for g_array_free
The text about deallocation of GArrays with elements containing
dynamically-allocated memory was confusing. It initially mentioned
clear_func, but later said elements with dynamically allocated memory
"should be freed separately".

Clarify this by using the same structure as g_ptr_array_free —
highlight the need to set a clear_func by consolidating the text about
it in a separate paragraph.

https://gitlab.gnome.org/GNOME/glib/merge_requests/348
2018-09-24 16:34:53 +02:00
Debarshi Ray
30ccd6f01b docs: Use the correct terminology for g_array_free
GArray uses the term clear_func (eg., g_array_set_clear_func), while
element_free_func comes from GPtrArray.

https://gitlab.gnome.org/GNOME/glib/merge_requests/348
2018-09-24 16:34:49 +02:00
Xavier Claessens
8391219e4c Meson: Run in TAP mode installed tests that support it 2018-09-23 13:44:15 -04:00
Xavier Claessens
96fafcfe92 Meson: Fix missing files when installing tests
Closes #1527
2018-09-21 08:45:02 -04:00
Will Thompson
63f8294c45
gkeyfile: remain usable after g_key_file_free()
Previously, in the case where 'kf' has more than one ref, calling
g_key_file_free(kf) would break it. For example, calling
g_key_file_has_key(kf, ...) would hit the following assertion:

    g_hash_table_lookup: assertion 'hash_table != NULL' failed

This is because g_key_file_free() calls g_key_file_clear() which sets
self->groups and other fields to NULL; most lookup functions assume
these fields are non-NULL.

One fix would be to call g_key_file_init() right after
g_key_file_clear() in g_key_file_free(). However, in the case where
there are no other refs to the keyfile, this would mean allocating
many new hash tables which will be immediately destroyed when
g_key_file_unref() removes the last ref. Instead, inline the unref, and
re-initialize the internal state when the keyfile is still alive.
2018-09-20 17:04:00 +01:00
Mikhail Fludkov
1f6db2a5c5 glib/gcharset: fix leaking g_get_language_names_with_category 2018-09-20 16:08:19 +02:00
Руслан Ижбулатов
b9f91437bb Fudge glib fileutils test to pass on Windows
1) Creating a directory with 0666 does not prevent
traversal on Windows (ACL determines the possibility
of traversal, and Windows mkdir() does not translate
permission bits into ACL). Don't do the traversal check on Windows.

2) Creating a file with 0555 also isn't translated into
read-only ACL, Windows sets the read-only attribute instead,
which blocks all changes, including changes to file times.
Add the write permissions on Windows before changing file times.
2018-09-18 12:45:06 +00:00
Руслан Ижбулатов
d3d6ef60c6 W32: drop _wstat64(), get stat data manually
It turns out that UCRT (which is the C runtime that Visual Studio
uses by default these days) quietly changed the semantics for
stat() functions and its variants. Previously they provided data
for the symlink (if the file queried was a symlink), now they
provide data for the target of the symlink.

glib used to call _wstat64() to get certain stat-ish data about
files, such as st_dev, since it was deemed that computing that
data in glib using custom code would be pointless, as _wstat64()
worked just fine.

With UCRT this is no longer true. This commit drops _wstat64() in
favour of a bunch of custom calls that populate the stat buffer
manually. This way glib correctly gets information about a symlink,
not its target.

The _fstat64() call is still being used, as it does not suffer
from this problem and thus remains untouched.
2018-09-18 12:45:05 +00:00
Hans Petter Jansson
171f698ead ghash: Simplify g_hash_table_set_shift()
Even if we're using a prime modulo for the initial probe, our table is
power-of-two-sized, meaning we can set the mask simply by subtracting one
from the size.
2018-09-17 16:17:10 +02:00
Hans Petter Jansson
0dee62973c ghash: Fix poor performance with densely populated keyspaces
Sequential integers would be densely packed in the table, leaving the
high-index buckets unused and causing abnormally long probes for many
operations. This was especially noticeable with failed lookups and
when "aging" the table by repeatedly inserting and removing integers
from a narrow range using g_direct_hash() as the hashing function.

The solution is to multiply the hash by a small prime before applying
the modulo. The compiler optimizes this to a few left shifts and adds, so
the constant overhead is small, and the entries will be spread out,
yielding a lower average probe count.
2018-09-17 15:28:11 +02:00
Руслан Ижбулатов
256e741248 W32: tighten access rights requested to read symlink
According to
http://blog.kalmbach-software.de/2008/02/28/howto-correctly-read-reparse-data-in-vista/
we only need FILE_READ_EA, and should also use wider share flags.
2018-09-12 14:35:14 +00:00
Руслан Ижбулатов
a86eb1a8b6 W32: test the private path-stripping function 2018-09-12 14:35:13 +00:00
Руслан Ижбулатов
05fdd09740 W32: Don't always strip path prefixes
Extended path prefix looks like "\\?\",
and NT object path prefix looks like "\??\".
Strip them only if they are followed by a character
(any character) and a colon (:), indicating that
it's a DOS path with a drive.
Otherwise stripping such prefix might result in a patch
that looks like a relative path.

For example, "\\?\Volume{GUID}\" becomes "Volume{GUID}\",
which is a valid directory name.

Currently it's up to the user to make sense of such paths.
2018-09-12 14:35:09 +00:00
Emmanuele Bassi
86ab6ffa8d Merge branch '303-list-store-tests' into 'master'
Add more GListStore/GListModel tests

See merge request GNOME/glib!304
2018-09-05 11:11:58 +00:00
Philip Withnall
d2f412590e Merge branch 'wip/gtimeval-document-year-2038-problem' into 'master'
Document that GTimeVal is subject to the year 2038 problem on 32-bit systems

See merge request GNOME/glib!302
2018-09-05 10:55:43 +00:00
Philip Withnall
dfa2a4ae75 gtestutils: Print non-matching stderr/stdout output on trap failure
When running a test as a subprocess and matching its output, it’s very
annoying for GLib to tell you that the output didn’t match your pattern,
*but not actually say what the output was*. Fix that.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-09-05 11:25:03 +01:00
Emmanuele Bassi
515c39b0a9 Merge branch '1493-dtrace-consts' into 'master'
dtrace: Add missing const attributes to types in glib_probes.d

See merge request GNOME/glib!272
2018-09-05 10:13:14 +00:00