Commit Graph

23514 Commits

Author SHA1 Message Date
demotomohiro
56d5d9eda6
Fix annotation of count arguments 2021-04-07 04:13:26 +09:00
Benjamin Berg
40a46d1346 gsocks5proxy: Handle EOF when reading from a stream
The code did not handle EOF (0 byte read) correctly. This can e.g. cause
an infinite loop if an incorrect socks proxy is configured.

Add the appropriate checks and return an G_IO_ERROR_CONNECTION_CLOSED
error if EOF is encountered.
2021-04-06 17:01:03 +02:00
Philip Withnall
1059b7eae1 Merge branch 'mcatanzaro/coverity' into 'master'
Fix a handful of minor leaks found by Coverity

See merge request GNOME/glib!2027
2021-04-05 16:44:35 +00:00
Sebastian Dröge
9dac3ff498 Merge branch 'fix_more_warnings' into 'master'
Fix more warnings

See merge request GNOME/glib!1957
2021-04-05 10:42:33 +00:00
Emmanuel Fleury
eafc764bb2 Fix several signedness warnings in gio/tests/converter-stream.c:main()
gio/tests/converter-stream.c: In function ‘main’:
gio/tests/converter-stream.c:1220:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
 1220 |   for (i = 0; i < G_N_ELEMENTS (compressor_tests); i++)
      |                 ^
gio/tests/converter-stream.c:1223:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
 1223 |   for (i = 0; i < G_N_ELEMENTS (truncation_tests); i++)
      |                 ^
gio/tests/converter-stream.c:1226:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
 1226 |   for (i = 0; i < G_N_ELEMENTS (charset_tests); i++)
      |                 ^
2021-04-05 12:03:51 +02:00
Emmanuel Fleury
88253f171c Fix signedness warning in gio/tests/contenttype.c
gio/tests/contenttype.c: In function ‘test_tree’:
gio/tests/contenttype.c:337:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
  337 |   for (i = 0; i < G_N_ELEMENTS (tests); i++)
      |                 ^
2021-04-05 12:03:51 +02:00
Emmanuel Fleury
8bcb2b9e76 Fix several signedness warnings in gio/tests/contexts.c
gio/tests/contexts.c: In function ‘test_context_specific_emit’:
gio/tests/contexts.c:379:21: error: comparison of integer expressions of different signedness: ‘guint’ {aka ‘unsigned int’} and ‘gint32’ {aka ‘int’}
  379 |       for (i = 0; i < g_test_rand_int_range (1, 5); i++)
      |                     ^
gio/tests/contexts.c:383:55: error: comparison of integer expressions of different signedness: ‘int’ and ‘guint’ {aka ‘unsigned int’}
  383 |         while (g_atomic_int_get (&observed_values[i]) != n)
      |                                                       ^~
gio/tests/contexts.c:387:41: error: comparison of integer expressions of different signedness: ‘gint64’ {aka ‘long int’} and ‘guint64’ {aka ‘long unsigned int’}
  387 |             if (g_get_monotonic_time () > expiry)
      |                                         ^
2021-04-05 12:03:51 +02:00
Emmanuel Fleury
a7d3ecca77 Fix signedness warning in gio/gsettings-tool.c
gio/gsettings-tool.c: In function ‘gsettings_list_children’:
gio/gsettings-tool.c:199:30: error: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘gint’ {aka ‘int’}
  199 |     if (strlen (children[i]) > max)
      |                              ^
2021-04-05 12:03:51 +02:00
Emmanuel Fleury
0214d892ba Fix unecessary assert with always true assertions in gio/gresource-tool.c
gio/gresource-tool.c: In function ‘elf_foreach_resource_section’:
gio/gresource-tool.c:190:22: error: comparison of unsigned expression in ‘>= 0’ is always true
  190 |   g_assert (shstrndx >= 0);
      |                      ^~
gio/gresource-tool.c:193:19: error: comparison of unsigned expression in ‘>= 0’ is always true
  193 |   g_assert (shnum >= 0);
      |                   ^~
2021-04-05 12:03:51 +02:00
Emmanuel Fleury
1f23770bc3 Fix signedness warning in gio/gunixsocketaddress.c
gio/gunixsocketaddress.c: In function ‘g_unix_socket_address_to_native’:
gio/gunixsocketaddress.c:217:15: error: comparison of integer expressions of different signedness: ‘gsize’ {aka ‘long unsigned int’} and ‘gssize’ {aka ‘long int’}
  217 |   if (destlen < socklen)
      |               ^
2021-04-05 12:03:51 +02:00
Emmanuel Fleury
5fec112453 Fix signedness warning in gio/giomodule.c
gio/giomodule.c: In function ‘print_help’:
glib/gmacros.h:806:26: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’}
  806 | #define MAX(a, b)  (((a) > (b)) ? (a) : (b))
      |                          ^
../glib.git/gio/giomodule.c:733:19: note: in expansion of macro ‘MAX’
  733 |           width = MAX (width, strlen (g_io_extension_get_name (extension)));
      |                   ^~~
2021-04-05 12:03:51 +02:00
Bruce Cowan
e0bd609f76 Update British English translation
(cherry picked from commit e0c0342688)
2021-04-02 13:25:01 +00:00
Michael Catanzaro
8bfc299813 gfileenumerator: fix leak in error path
Found by Coverity.
2021-04-01 14:28:10 -05:00
Michael Catanzaro
719484a575 gdbusobjectmanagerservice: fix leak in error path
If the third g_return_val_if_fail() is hit, then we leak
orig_object_path. There is no reason we need to strdup it here.

Found by Coverity.
2021-04-01 14:28:10 -05:00
Michael Catanzaro
2b29495bcb gdbusauth: fix error leak
local_error is leaked in the G_IO_ERROR_NOT_SUPPORTED case. Found by
Coverity.
2021-04-01 14:28:10 -05:00
Michael Catanzaro
65b4bc30eb gapplication: fix arguments leak in error path
If this g_return_val_if_fail() is ever hit, then we leak arguments.
This is not very important because if your code hits
g_return_val_if_fail() you are invoking undefined behavior, a rather
more serious problem, but let's replace it with g_critical() to be
robust.

This includes a small behavior change: it returns 1 rather than 0 in
this error case.

Found by Coverity.
2021-04-01 14:27:31 -05:00
Michael Catanzaro
e2f2706539 Fix small file leak in fuzzing driver
This doesn't matter as the file is needed until right before the program
quits, but it placates Coverity.
2021-04-01 14:27:03 -05:00
Philip Withnall
32fc1e6bbf Merge branch 'th/gdbus-cleanup' into 'master'
[th/gdbus-cleanup] two minor cleanup patches for gdbusconnection.c

See merge request GNOME/glib!2025
2021-04-01 11:34:52 +00:00
Thomas Haller
090eeabe9c gdbus: simplify error handling in g_dbus_connection_send_message_unlocked()
"goto out" is a fine pattern, especially when we are not using
cleanup attribute macros.

But in this case it was unnecessary.
2021-03-31 20:56:45 +02:00
Thomas Haller
60d4092a2c gdbus: refactor duplicate code for freeing FilterData 2021-03-31 20:56:45 +02:00
Philip Withnall
e7f6799668 Merge branch '2055-correct-date-format-utf8' into 'master'
Resolve "g_date_time_format() does not return UTF-8 if LC_TIME is not UTF8 but other locale settings are UTF-8"

Closes #2055

See merge request GNOME/glib!1777
2021-03-31 16:16:16 +00:00
Philip Withnall
f0afc3ed53 Merge branch 'remove-shgetfileinfo' into 'master'
GWin32Mount: Remove SHGetFileInfoW()

Closes #2096

See merge request GNOME/glib!2020
2021-03-31 13:49:36 +00:00
Руслан Ижбулатов
cb994350c4 GWin32Mount: Don't use SHGetFileInfoW() for mount displaynames
This function can create long delays when used on disconnected
or just weird volumes. Use IShellFolder::GetDisplayNameOf() instead.

Fixes #2096
2021-03-31 13:30:03 +00:00
Руслан Ижбулатов
d1c542254f GWin32Mount: Don't use SHGetFileInfoW() for icons
This function can cause significant delays when the mounted volume
is disconnected or just weird. Use IExtractIconW::GetIconLocation()
instead.

Theoretically, this should require COM to be initialized, but in my tests
this code worked just fine without calling CoInitializeEx().
2021-03-31 13:30:02 +00:00
Philip Withnall
4cce4b96a6 Merge branch 'ricotz/for-master' into 'master'
gtlspassword: Fix g-i annotation of return for g_tls_password_get_value

See merge request GNOME/glib!2023
2021-03-31 12:10:10 +00:00
Rico Tzschichholz
454a9c1203 gtlspassword: Fix g-i annotation of return for g_tls_password_get_value 2021-03-31 12:10:10 +00:00
Philip Withnall
0ac0e49058 Merge branch 'exfat' into 'master'
glocalfile: Add native exfat magic number to filesystem list

Closes #2369

See merge request GNOME/glib!2019
2021-03-31 12:07:49 +00:00
Philip Withnall
16c4a9a57e Merge branch 'clang-cl-improvements' into 'master'
Some improvements to clang-cl builds

Closes #2338 and #2357

See merge request GNOME/glib!2004
2021-03-31 11:25:56 +00:00
Chun-wei Fan
35154a3519 glib-sections.txt: Add g_macro__has_extension in private section
This should satisfy the documentation build check.
2021-03-31 10:50:27 +08:00
Chun-wei Fan
f801c84c52 gmacros.h: Improve check for C _Static_assert
Use the GCC/Clang macros __has_extension() and __has_feature() on
c_static_assert, which is the documented way for GCC/CLang to check for
_Static_assert if C11 mode is not enabled, as suggested by Aleksandr Mezin.

As a result, add a private macro that is defined to be __has_extension if it
exists, otherwise it is considered to be always false.
2021-03-30 16:45:07 +08:00
Chun-wei Fan
7b76995298 gmacros.h: Use _Static_assert for clang
It appears that CLang supports _Static_assert() even when not in C11
mode, since at least CLang 3.1, so let's just use that for CLang builds.

Fixes issue #2338.
2021-03-30 16:45:07 +08:00
Chun-wei Fan
97959cd7eb msvc_recommended_pragmas.h: Refine for clang-cl
Make msvc_recommended_pragmas.h work better with clang-cl so that we can
use that to eliminate some warnings that are emitted as it also consumes
Microsoft compiler and SDK headers.

Also, for GLib builds, force-include msvc_recommended_pragmas.h for
clang-cl builds as well, as it becomes usable and useful there.

Fixes issue #2357.
2021-03-30 16:45:07 +08:00
Leigh Scott
762b284ecc glocalfile: Add native exfat magic number to filesystem list 2021-03-29 18:33:31 +01:00
Philip Withnall
622b31f69e Merge branch 'fixing_2281' into 'master'
Update GFileInfo to use GDateTime as timestamps

Closes #2281

See merge request GNOME/glib!2017
2021-03-29 16:47:58 +00:00
Philip Withnall
e42aff2592 Merge branch 'gio-appinfo-thread-crash' into 'master'
GIO W32: Pin gio DLL

Closes #2300 and #2359

See merge request GNOME/glib!2016
2021-03-29 16:34:04 +00:00
Abanoub Ghadban
1bdfc1a36b gfileinfo: Add tests for get and set {access,creation}_date_time APIs 2021-03-28 23:07:39 +02:00
Abanoub Ghadban
240cc7da97 gfileinfo: Add APIs to get and set {access,creation}_date_time 2021-03-28 23:07:39 +02:00
Dz Chen
7629fdaaeb Update Chinese (China) translation 2021-03-27 23:39:12 +00:00
Frederic Martinsons
782eb1f7af Add private functions to correctly convert datetime when LC_TIME is not UTF8
Functions (_g_get_time_charset and _g_get_ctype_charset) to get LC_TIME and LC_CTYPE charset
by using nl_langinfo with _NL_TIME_CODESET and CODESET).
Another functions (_g_locale_time_to_utf8 and _g_locale_ctype_to_utf8) which uses thel and format
the input string accordingly.
Add new test cases with mixing UTF8 and non UTF8 LC_TIME along with UTF8
and non UTF8 LC_MESSAGES.

Closed #2055

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-03-27 09:28:10 +01:00
Frederic Martinsons
c4df3b23c4 Reorganize headers inclusion alphabetically
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-03-27 08:29:08 +01:00
Frederic Martinsons
b4f2002919 Correct FIXME by implementing a function for converting two digits year
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-03-27 08:29:08 +01:00
Simon McVittie
6d50032167 Merge branch 'fuzz-path-fix' into 'master'
fuzzing: Fix assertion failure in fuzz_paths.c

See merge request GNOME/glib!2013
2021-03-25 17:28:20 +00:00
Simon McVittie
760ba5c4f1 Merge branch '2363-alloca-docs' into 'master'
galloca: Clarify alloca() sizes must always be controlled by the program

Closes #2363

See merge request GNOME/glib!2014
2021-03-25 17:27:23 +00:00
Руслан Ижбулатов
03b574ae66 Don't leak a handle from _g_io_win32_get_module()
This call increments the DLL refcount by default and
needs a flag to avoid that.
2021-03-25 15:20:49 +00:00
Руслан Ижбулатов
f701d6c497 GIO W32: Pin gio DLL
On Windows gio runs a thread to update appinfo at startup.
If someone unloads gio (this happens when a dynamic gio module gets
unloaded by a program that doesn't use gio itself), there doesn't seem
to be a way to detect that until gio is already gone, and as soon as
gio is gone, the thread crashes, since it tries to execute instructions
that are no longer there.

Holding an extra reference to gio DLL fixes this, but it also prevents
gio from being unloaded, and there's no "weak references" for DLLs.
So we just pin gio and acknowledge that it will never be unloaded.

Fixes #2300
Fixes #2359
2021-03-25 15:16:08 +00:00
Philip Withnall
b657e78add galloca: Clarify alloca() sizes must always be controlled by the program
To avoid security vulnerabilities.

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

Fixes: #2363
2021-03-25 12:55:21 +00:00
Philip Withnall
c3eb4a939b fuzzing: Fix assertion failure in fuzz_paths.c
If operating on a zero-length input, the return values of
`g_path_get_basename()` and `g_path_get_dirname()` are correctly `.`.
The assertions in the test didn’t account for this.

oss-fuzz#32454

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-03-25 11:23:55 +00:00
Philip Withnall
55cbc31517 Merge branch 'master' into 'master'
make g_tree_remove_all public

See merge request GNOME/glib!1986
2021-03-24 12:13:18 +00:00
Philip Withnall
eaaa41f98f Merge branch 'fuzz-path-functions' into 'master'
fuzzing: Add fuzz tests for functions which parse paths

See merge request GNOME/glib!2006
2021-03-24 11:16:49 +00:00
Philip Withnall
1140c228ab fuzzing: Add fuzz tests for functions which parse paths
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-03-24 11:16:49 +00:00