Commit Graph

18260 Commits

Author SHA1 Message Date
Bastien Nocera
cb8c919952 simpleproxyresolver: Don't crash on invalid hostname
Check for g_hostname_to_ascii() failure, rather than crashing when
checking whether an invalid hostname should go through the proxy.

The HTTP library should report the error about the invalid hostname
once we actually try to connect to it.

https://bugzilla.gnome.org/show_bug.cgi?id=772989
2018-02-01 14:17:50 +00:00
Ignacio Casal Quinteiro
1a99154898 gpollableoutputstream: document side effects of WOULD_BLOCK on D/TLS
If the underlying transport is D/TLS the same data and data length
is required to be sent on the next iteration when a WOULD_BLOCK
happens. This is due to the fact that gnutls or openssl keep
an internal state for the data.

https://bugzilla.gnome.org/show_bug.cgi?id=792862
2018-01-31 22:37:18 +00:00
Philip Withnall
4752d72a60 gdbusaddress: Disable proxy support for D-Bus addresses
See the discussion in the bug report: with proxy support enabled, a
proxy resolver is created. Doing that will load all the GIO modules, and
typically at least one of them will try to use GDBus during
initialisation, which will cause a deadlock.

Using a TCP address with GDBusAddress is still supported, but accessing
it over a proxy is not.

Document this.

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

https://bugzilla.gnome.org/show_bug.cgi?id=792499
2018-01-31 22:25:02 +00:00
Iñigo Martínez
3ef83618d9 gdbus-codegen: Improve documentation
Recent changes has extended the functionality of `gdbus-codegen`
by implementing new options.

This patch extends the documentation including the behaviour of
the new options along the old ones.

(Wording tweaked by Philip Withnall before pushing.)

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-31 22:14:04 +00:00
Iñigo Martínez
93042e0052 gdbus-codegen: Fix issue with docbook generation
In cases where gdbus-codegen is used only for docbook generation,
the execution stops with the following error message:

  `Using --header or --body requires --output`

This is because it was assumed that, in addition to the docbook
generation, the header or source code were always generated.

This patch fixes this, and the header or source code generation
is not mandatory, so the docbook can be generated separately.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-31 22:12:51 +00:00
Pavlo Solntsev
382d13b618 Clarification for memmory allocation function
Difference between g_try_... family of functions and their counterparts
has been clarified.

https://bugzilla.gnome.org/show_bug.cgi?id=792903
2018-01-31 22:10:51 +00:00
Ondrej Holy
7e0d42e3dc gunixmounts: Skip accumulated events from file monitor
Skip accumulated events from file monitor which we are not able to handle
in a real time instead of emitting mounts_changed signal several times.
This should behave equally to GIOChannel based monitoring. See Bug 792235.

https://bugzilla.gnome.org/show_bug.cgi?id=793006
2018-01-30 15:31:13 +01:00
Emmanuele Bassi
c1d58dd7e0 build: Document the chmod-scripts configure command
The chmod of all the scripts we generate from a template via configure
is necessary because configure will not preserve the bits of the
template when generating a new file.

There's no explanation for it, and you have to hunt it down the commit
history. Since Meson does the right thing, we added the executable bit
on the templates, but we cannot remove the AC_CONFIG_COMMANDS macro from
the Autotools build without breaking it. Let's document this, to avoid
nasty surprises.
2018-01-30 11:18:34 +00:00
Christian Hergert
47b78e6d83 tests: additional test for g_bytes_new_from_bytes()
This adds two new tests for g_bytes_new_from_bytes().

One test ensures that when creating a new GBytes that is a slice of
the entire base bytes, we just return the base bytes with it's reference
count incremented by one.

The other test ensures that when performing sub-slices of GBytes, for
which the parent GBytes also references a GBytes, that we skip the
intermediate GBytes and reference the base GBytes. Additional testing
of the internal state of the GBytes structure is performed to prove
the correctness of the implementation.

https://bugzilla.gnome.org/show_bug.cgi?id=792780
2018-01-27 11:43:38 -08:00
Christian Hergert
4151bce6db bytes: avoid intermediate refs in g_bytes_new_from_bytes()
When referencing a GBytes that is already a slice of another GBytes, we
can avoid referencing the intermediate GBytes and instead reference the
root bytes.

Doing so helps avoid keeping N GBytes instances alive when the
intermediates would have otherwise been finalized.

https://bugzilla.gnome.org/show_bug.cgi?id=792780
2018-01-27 11:43:38 -08:00
Bastien Nocera
801accf746 GNotification: Don't ignore set_urgent()'s argument
set_urgent() would behave is if @urgent was always true. The regression
was introduced in commit 01098e34c1

https://bugzilla.gnome.org/show_bug.cgi?id=792777
2018-01-23 14:24:12 +00:00
Philip Withnall
cea72036e3 gnotification: Add missing deprecation tag to set_urgent()
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=792777
2018-01-22 11:24:47 +00:00
Balázs Úr
66824159cd Update Hungarian translation 2018-01-21 21:27:00 +00:00
Mikhail Zabaluev
52f98911df Test that g_convert() can handle embedded NUL bytes
https://bugzilla.gnome.org/show_bug.cgi?id=792516
2018-01-19 11:46:31 +00:00
Mikhail Zabaluev
f35a6a7031 gconvert: Consistently validate inputs and outputs for embedded NULs
String inputs to convenience conversion functions g_locale_from_utf8(),
g_filename_from_utf8(), and g_filename_to_utf8(), are annotated for the
bindings as NUL-terminated strings of (type utf8) or (type filename).
There is also a len parameter that allows converting part of the string,
but it is exposed to the bindings as a value independent from the string
buffer. Absent any more sophisticated ways to annotate, the way to
provide a safeguard against len argument values longer than the
string length is to check that no nul is encountered within the first
len bytes of the string. strdup_len() includes this check as part of
UTF-8 validation, but g_convert() permits embedded nuls.

For g_filename_from_utf8(), also check the output to prevent embedded NUL
bytes. It's not safe to allow embedded NULs in a string that is going
to be used as (type filename), and no known bytestring encoding for
file names allows them.

https://bugzilla.gnome.org/show_bug.cgi?id=792516
2018-01-19 11:46:31 +00:00
Mikhail Zabaluev
d584ff77f6 Test embedded NULs in input of g_{locale,filename}_to_utf8()
The tests exercise both g_strncpy() and g_convert() paths.

https://bugzilla.gnome.org/show_bug.cgi?id=792516
2018-01-19 11:46:31 +00:00
Mikhail Zabaluev
81cd815406 gconvert: Tighten, document embedded NUL behavior of UTF-8 conversions
The character encoding conversion utility functions g_locale_to_utf8()
and g_filename_to_utf8() had inconsistent behavior on producing strings
with inner NUL bytes: in the all-UTF-8 strdup path, the input string
validation prohibits embedded NULs, while g_convert(), using iconv(),
can produce UTF-8 output with NUL bytes inside the output buffer.
This, while valid UTF-8 per the Unicode standard, is not valid for
the nul-terminated (type utf8) return value format that the *_to_utf8()
functions are annotated with (as per discussion in bug 756128).

Check the output of g_convert() for embedded NUL bytes, and if any
are found, set the newly introduced error
G_CONVERT_ERROR_EMBEDDED_NUL.

Also document the error set by g_{locale,filename}_{from,to}_utf8()
when the input string contains nul bytes.

https://bugzilla.gnome.org/show_bug.cgi?id=792516
2018-01-19 11:46:31 +00:00
Mikhail Zabaluev
413605a6f3 gconvert: Optimize UTF-8 conversions, fix output on error
In the strdup_len() path, no need to do what g_utf8_validate()
already does: locate the string-terminating nul byte.

Also in strdup_len(), make the out parameter bytes_read receive the length
of the valid (meaning also nul-free) part of the input string, as the
documentation on g_{locale,filename}_{from,to}_utf8() says it does.

https://bugzilla.gnome.org/show_bug.cgi?id=792516
2018-01-19 11:46:31 +00:00
Philip Withnall
1e6803be3b gmain: Partial revert of recent wakeup changes to gmain.c
This reverts the following commits (but keeps the other recent changes
to gmain.c):
 • e4ee3079c Do not wake up main loop if change is from same thread
 • 208702404 main: Create a helper function for "owner wakeup" optimization
 • 0c0469b56 gmain: Signal wakeups if context has never been acquired as well
 • 9ba95e25b gmain: only signal GWakeup right before or during a blocking poll

Some combination of them is causing problems with LibreOffice and/or
WebKit, and the safest thing to do at the moment is revert them all
until we work out what’s going on. The previous revert (4976e8109) was
not sufficient (it fixed WebKit, but re-broken LibreOffice).

By reverting, we gain some spurious wakeups, but avoid dropping
necessary wakeups, which is presumably what’s causing problems in the
other modules.

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

https://bugzilla.gnome.org/show_bug.cgi?id=761102
2018-01-18 11:31:08 +00:00
Philip Withnall
3787e42932 gio: Rename GNetworkMonitorWindows to GWin32NetworkMonitor
This makes it more consistent with other GWin32* objects. No functional
changes.

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

https://bugzilla.gnome.org/show_bug.cgi?id=685442
2018-01-18 10:12:26 +00:00
Philip Withnall
ba976f13b6 gio: Rename gnetworkmonitorwindows to gwin32networkmonitor
This makes it more consistent with the other win32 objects in GIO. This
commit just renames the files; a follow-up commit will rename the
GObject.

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

https://bugzilla.gnome.org/show_bug.cgi?id=685442
2018-01-17 12:59:51 +00:00
Jan-Michael Brummer
f9aacf3952 GNetworkMonitorWindows: Add IPv4/IPv6 network monitor backend for windows
Added a Windows backend to GNetworkMonitor, using NotifyRouteChange2()
(available on Vista and later). It marshals the route change callbacks
to the thread-specific default main context the GNetworkMonitor was
constructed in.

https://bugzilla.gnome.org/show_bug.cgi?id=685442
2018-01-17 12:31:26 +00:00
Sébastien Wilmet
3ee859d5fc docs: GSequence: better document how to sort large amount of data
It was documented at strange places: in g_sequence_search*() and
g_sequence_lookup*(), but how to insert and sort data is not done by
those functions.

So instead, add the information to the class description (since it
involves several functions), and add also the information in
g_sequence_insert_sorted() and g_sequence_insert_sorted_iter() as a kind
of warning when using those functions.

Note that before this commit, it was not explained *why* it is better to
call g_sequence_sort() after doing a lot of unsorted insertions. Now it
is documented as "more efficient" (I think it's the only reason that
makes sense, otherwise why was it documented?).

https://bugzilla.gnome.org/show_bug.cgi?id=792455
2018-01-16 20:11:31 +01:00
Emmanuele Bassi
c685ce973d Fix dir separator in the Autotools build on Windows
Just like we fixed the Meson build in commit f25c7a2a, we need to escape
twice: once for the shell expansion, and the other for the C string
constant.
2018-01-16 15:19:41 +00:00
Emmanuele Bassi
dcfa22549a docs: Small improvements to glib-mkenums man page
Clarify some typical usage of glib-mkenums and its substitutions.
2018-01-16 15:17:54 +00:00
Emmanuele Bassi
e6c3060144 docs: Drop references to Perl in glib-mkenums
The tool was ported to Python, but we should not mention the programming
language used, in case we port it to some other language in the distant
future.
2018-01-16 15:17:53 +00:00
Benjamin Berg
5fba62adec gmessages: Flush output stream after logging messages
When debug output is enabled then certain messages will be logged to
stdout. stdout however is block buffered by default when it isn't going
to a TTY meaning that debug logging will not be flushed out properly
when it is being redirected. One example of this happening may be tests
that rely on parsing g_debug messages.

Adding an explicit fflush ensures all log messages will reach the output.

https://bugzilla.gnome.org/show_bug.cgi?id=792432
2018-01-15 19:46:22 +01:00
Philip Withnall
051d69bbc8 gdataset: Fix a typo in a documentation comment
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-15 18:26:56 +00:00
Colin Walters
4808a957b5 GFile: Add g_file_peek_path()
This is a variant of g_file_get_path() which returns a const string to
the caller, rather than transferring ownership.

I've been carrying `gs_file_get_path_cached()` in libgsystem and it
has seen a lot of use in the ostree and flatpak codebases.  There are
probably others too.

I think language bindings like Python/Gjs could also use this to avoid
an extra malloc (i.e. we could transparently replace
`g_file_get_path()` with `g_file_peek_path()`.

(Originally by Colin Walters. Tweaked by Philip Withnall to update to
2.56, change the function name and drop the locking.)

https://bugzilla.gnome.org/show_bug.cgi?id=767976
2018-01-15 18:26:56 +00:00
Iñigo Martínez
261cb8ea86 gdbus-codegen: Set source coding to utf-8
Some of the recent changes introduced UTF-8 characters which made
gdbus-codegen to crash when using Python 2.

Following PEP 263, the utf-8 coding comment has been used.

PEP: https://www.python.org/dev/peps/pep-0263/
BUG: https://bugzilla.gnome.org/show_bug.cgi?id=791015

Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
2018-01-15 17:04:31 +01:00
Philip Withnall
88101e5981 docs: Add missing apostrophes in GObject documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-15 15:35:45 +00:00
Iñigo Martínez
e4d68c7b3e gdbus-codegen: Support for separate C header and code generation
gdbus-codegen's options only allow a simultaneous header and source
code generation.

A `--header` and `--body` options have been added along with the
`--output` option which allow separate C header and code
generation.

These options cannot be used in addition to the old options such
as `--generate-c-code`, `--generate-docbook` or
`--output-directory`.

These options have also been added to gdbus-codegen's documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:11:17 +01:00
Iñigo Martínez
6c3af1cdda gdbus-codegen: Remove unnecessary parameters from the constructor
The `outdir` and `docbook` parameters are passed to the
`DocbookCodeGenerator` constructor, but these parameters are only
used at docbook generation, which is optional.

The parameters have been removed from the class creation and added
to the `generate` method, where they are actually being used.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:10:12 +01:00
Iñigo Martínez
22772acff8 gdbus-codegen: Split C header and code generation
The class that generated both C header and code has been split into
two classes. These clases are now specialized on creating the header
or the body code.

All parameters that do not belong to each class have also been
deleted, so only the necessary parameters still remain. These also
includes the header and code file descriptors, leaving only the
corresponding file descriptor necessary for each class.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:07:07 +01:00
Iñigo Martínez
a66f2f80e0 gdbus-codegen: Split C header and code generation functions
The generation of the C header and code preambles have been split
in order to be able to generate both files separately in the future.

The functions for generating preambles and postambles have also been
renamed following the function names used in the glib-genmarshal
rewrite, so that they stay consistent.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:06:01 +01:00
Iñigo Martínez
c658d03b76 gdbus-codegen: Add support for pragma inclusion guard
The #pragma once is widely supported preprocessor directive that can
be used instead of include guards.

This adds support for using optionally this directive instead of
include guards.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:05:26 +01:00
Iñigo Martínez
e59bce3c74 gdbus-codegen: Move from optparse to argparse
The optparse module is deprecated since version 2.7 and the
development continues with the argparse.

The code has been moved from optparse to argparse when parsing
command-line options. This has also led to the deprecation of the
`--xml-files`, and positional arguments should be used instead.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:03:39 +01:00
Iñigo Martínez
dcc1fe09d0 gdbus-codegen: Use Color's print_* methods
`glib-genmarshal` and `glib-mkenums` use a `Color` class which
implements a number of print_* methods to print colored messages
to the standard error output.

In order to be consistent with those programs' output,
`gdbus-codegen` has also started using that same class and methods.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:03:03 +01:00
Iain Lane
e2054240c2 gdatetime: Mark the usecs as volatile
On i386, we were seeing that this calculation was producing an incorrect
result, probably because usec was being stored in an 80-bit register
before being written back into a 64-bit float in memory. If we mark the
variables as volatile, they are not stored in registers and we avoid
this bug.
2018-01-15 11:54:47 +00:00
Robert Ancell
d870628782 gdatetime: Avoid repeated floating point multiplies with ISO 8601 parsing
This avoids any potential rounding errors.

https://bugzilla.gnome.org/show_bug.cgi?id=792410
2018-01-15 11:54:47 +00:00
Philip Withnall
e430541378 docs: Remove XML-style comments from documentation strings
gtk-doc doesn’t support them any more since it was ported to Markdown,
so they end up appearing in the generated documentation, which isn’t
great.

Mostly, they were used to split up things invisibly, which we can do in
other ways.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-12 15:29:29 +00:00
Philip Withnall
d3b07453ab docs: Add a link to the Wikipedia page on TOCTTOU races
Try and make it a bit more obvious that g_file_query_exists() is
generally A Bad Idea.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-12 12:10:16 +00:00
Philip Withnall
373bf178b6 docs: Fix syntax in GDBusInterfaceSkeleton documentation
gtk-doc was mis-parsing the combination of ` and :: and truncating some
of the documentation. Avoid that by using the D-Bus style of separating
interface and signal names using a dot.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-11 16:03:05 +00:00
Philip Withnall
9c638bbf04 docs: Fix a typo in the GDBusProxy documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-11 15:31:17 +00:00
Garrett Regier
6aa19a26cf gsequence: Add seq_is_end()
This avoids calling is_end() when the
GSequence is already determined, thus
avoids having to walk the tree.

https://bugzilla.gnome.org/show_bug.cgi?id=749583
2018-01-11 12:47:18 +00:00
Garrett Regier
ee8f7be3df gsequence: Kill check_iter_access()
Generally the GSequence has already been
determined by the caller. This saves quite
a few calls to get_sequence().

https://bugzilla.gnome.org/show_bug.cgi?id=749583
2018-01-11 12:46:57 +00:00
Philip Withnall
d020766325 docs: Fix typos in GConvert documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-11 11:54:14 +00:00
Tim-Philipp Müller
59c5b939e2 glib: fix compiler warning for g_unsetenv_utf8() on windows
"warning: 'void' function returning a value". Neither
g_unsetenv_utf8() nor g_unsetenv() return anything.
2018-01-10 17:24:36 +00:00
Tim-Philipp Müller
b241e3a5cc meson: only add -fno-strict-aliasing if supported by compiler
Fixes warning spam on MSVC builds.

https://bugzilla.gnome.org/show_bug.cgi?id=791622
2018-01-10 17:00:14 +00:00
Tim-Philipp Müller
f25c7a2a6e meson: fix G_DIR_SEPARATOR* define on Windows
Must double escape, once for Meson, once for the C string constant.

https://bugzilla.gnome.org/show_bug.cgi?id=757284
2018-01-10 15:57:46 +00:00