Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
|
|
This will allow using the xdgmime test programs as a meson subproject.
|
|
Pass the xdg-mime path to the shared-mime-info build system so that it
actually uses our newly built binaries. This was always broken since
shared-mime-info started using xdgmime as a submodule before xdgmime had
a CI.
|
|
|
|
Commit 7cc63be350a7 ("Makefile: Add support for POSIX make) changed
the compilation mode to strict ISO C99 (-std=c99), which removed the
declarations of strdup and strcasecmp. As the implicit return value is
int instead of char*, the upper address bytes are discarded on e.g.
x86_64 (sizeof(int) == 4), the resulting code crashes.
Add the declarations back by using Posix 2008 mode, and also include
strings.h where required for strcasecmp.
Compilation may still fail when the compiler binary is not available as
c99, .POSIX mode sets CC=c99. Use e.g. "CC=cc make all" to circumvent.
|
|
|
|
This change should prevent test file omissions like the one fixed in
https://gitlab.freedesktop.org/xdg/shared-mime-info/-/commit/66c73d06805f1e8613bb44cf97de1f223971c60c
Always print summary. The condition (error > 0 || failed > 0) was
incomplete: xmatch > 0 should have been checked as well.
shared-mime-info's test_mime.sh passes a list with many expected
failures to test-mime-data, so the condition failed > 0 is always true.
Therefore printing the summary unconditionally makes no difference,
unless there are other users of test-mime-data that don't have expected
failures in their test case lists.
|
|
|
|
|
|
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Fixes: #9
|
|
The function pointer casts silence the compiler and allow the code to
build (and even run in the typical case). However, when building with
control flow integrity checks, the runtime (rightfully) complains about
calling a function via a mismatched function pointer type.
|
|
shared-mime-info-2.1/xdgmime/src/print-mime-data.c:66: alloc_fn: Storage is returned from allocation function "fopen".
shared-mime-info-2.1/xdgmime/src/print-mime-data.c:66: var_assign: Assigning: "file" = storage returned from "fopen(filename, "r")".
shared-mime-info-2.1/xdgmime/src/print-mime-data.c:80: leaked_storage: Variable "file" going out of scope leaks the storage it points to.
78| {
79| printf ("Failed to allocate memory for file %s\n", filename);
80|-> return;
81| }
82|
shared-mime-info-2.1/xdgmime/src/test-mime-data.c:113: alloc_fn: Storage is returned from allocation function "fopen".
shared-mime-info-2.1/xdgmime/src/test-mime-data.c:113: var_assign: Assigning: "file" = storage returned from "fopen(path, "r")".
shared-mime-info-2.1/xdgmime/src/test-mime-data.c:131: leaked_storage: Variable "file" going out of scope leaks the storage it points to.
129| error++;
130|
131|-> return;
132| }
133|
|
|
|
|
xdgmimecache.c: In function ‘dump_glob_node’:
xdgmimecache.c:1064:19: warning: comparison of integer expressions of different signedness: ‘int’ and ‘xdg_uint32_t’ {aka ‘unsigned int’}
1064 | for (i = 0; i < n_children; i++)
| ^
xdgmimecache.c: In function ‘_xdg_test_cache_glob_dump’:
xdgmimecache.c:1082:19: warning: comparison of integer expressions of different signedness: ‘int’ and ‘xdg_uint32_t’ {aka ‘unsigned int’}
1082 | for (j = 0; j < n_entries; j++)
| ^
|
|
src/xdgmimecache.c:__gio_xdg_cache_list_mime_parents()
src/xdgmimecache.c: In function ‘__gio_xdg_cache_list_mime_parents’:
src/xdgmimecache.c:1021:21: error: comparison of integer expressions of different signedness: ‘int’ and ‘xdg_uint32_t’ {aka ‘unsigned int’}
1021 | for (j = 0; j < n_entries; j++)
| ^
src/xdgmimecache.c:1031:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘xdg_uint32_t’ {aka ‘unsigned int’}
1031 | for (k = 0; k < n_parents && p < 127; k++)
| ^
|
|
src/xdgmimecache.c:__gio_xdg_cache_mime_type_subclass()
src/xdgmimecache.c: In function ‘__gio_xdg_cache_mime_type_subclass’:
src/xdgmimecache.c:968:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘xdg_uint32_t’ {aka ‘unsigned int’}
968 | for (j = 0; j < n_parents; j++)
| ^
|
|
src/xdgmimecache.c: In function ‘cache_glob_node_lookup_suffix’:
src/xdgmimecache.c:532:37: error: comparison of integer expressions of different signedness: ‘int’ and ‘xdg_uint32_t’ {aka ‘unsigned int’}
532 | while (n < n_mime_types && i < n_children)
| ^
|
|
src/xdgmimecache.c: In function ‘cache_glob_lookup_fnmatch’:
src/xdgmimecache.c:453:21: error: comparison of integer expressions of different signedness: ‘int’ and ‘xdg_uint32_t’ {aka ‘unsigned int’}
453 | for (j = 0; j < n_entries && n < n_mime_types; j++)
| ^
|
|
src/xdgmimecache.c: In function ‘cache_magic_compare_to_data’:
src/xdgmimecache.c:260:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘xdg_uint32_t’ {aka ‘unsigned int’}
260 | for (i = 0; i < n_matchlets; i++)
| ^
|
|
src/xdgmimecache.c: In function ‘cache_magic_matchlet_compare’:
src/xdgmimecache.c:235:21: error: comparison of integer expressions of different signedness: ‘int’ and ‘xdg_uint32_t’ {aka ‘unsigned int’}
235 | for (i = 0; i < n_children; i++)
| ^
|
|
src/xdgmimecache.c:cache_magic_matchlet_compare_to_data()
src/xdgmimecache.c: In function ‘cache_magic_matchlet_compare_to_data’:
src/xdgmimecache.c:181:27: error: comparison of integer expressions of different signedness: ‘int’ and ‘xdg_uint32_t’ {aka ‘unsigned int’}
181 | for (i = range_start; i < range_start + range_length; i++)
| ^
src/xdgmimecache.c:190:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘xdg_uint32_t’ {aka ‘unsigned int’}
190 | for (j = 0; j < data_length; j++)
| ^
src/xdgmimecache.c:202:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘xdg_uint32_t’ {aka ‘unsigned int’}
202 | for (j = 0; j < data_length; j++)
| ^
|
|
src/xdgmimemagic.c:_xdg_mime_magic_matchlet_compare_to_data()
src/xdgmimemagic.c: In function ‘_xdg_mime_magic_matchlet_compare_to_data’:
src/xdgmimemagic.c:527:32: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’
527 | for (i = matchlet->offset; i < matchlet->offset + matchlet->range_length; i++)
| ^
src/xdgmimemagic.c:536:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’
536 | for (j = 0; j < matchlet->value_length; j++)
| ^
src/xdgmimemagic.c:548:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’
548 | for (j = 0; j < matchlet->value_length; j++)
| ^
|
|
src/xdgmimemagic.c: In function ‘_xdg_mime_magic_parse_magic_line’:
src/xdgmimemagic.c:406:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’
406 | if (bytes_read != matchlet->value_length)
| ^~
src/xdgmimemagic.c:426:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’
426 | if (bytes_read != matchlet->value_length)
| ^~
src/xdgmimemagic.c:464:34: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’
464 | if (matchlet->range_length == -1)
| ^~
src/xdgmimemagic.c:488:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’
488 | for (i = 0; i < matchlet->value_length; i = i + matchlet->word_size)
| ^
|
|
src/xdgmimeint.c: In function ‘_xdg_binary_or_text_fallback’:
src/xdgmimeint.c:195:28: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’}
195 | for (i = 0; i < 128 && i < len; ++i)
| ^
|
|
If the result from magic sniffing doesn't correspond to
any of the matching globs (even via inheritance), and
there *were* matching globs, then don't return the result
from magic sniffing. This is too unreliable, and contradicts
the fact that if there was just one glob, the glob would win
(not the magic). So in that case, fallback to one of the glob
matches.
This required removing the code in cache_magic_lookup_data
which "cleans up" the mimetypes list (from glob matches)
of any glob that doesn't have matching magic. This behaviour
isn't in the spec [1], and prevents having anything to fall
back to in the end, after noticing that the magic should
be ignored after all.
[1] https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.21.html#idm45992893989040
Context: https://gitlab.freedesktop.org/xdg/shared-mime-info/-/issues/138
|
|
|
|
See https://gitlab.gnome.org/GNOME/glib/merge_requests/733.
|
|
|
|
Kalev noted in
https://gitlab.gnome.org/GNOME/glib/commit/be7f40185fb2ce884112c1f8a4b196ea65350466
that we have a buffer underflow here in case the length of the MIME type
is less than two (in which case we wind up accessing negative indices of
the mime string).
https://bugzilla.gnome.org/show_bug.cgi?id=708529
https://bugs.freedesktop.org/show_bug.cgi?id=100733
|
|
As noted by Alexandru Pandelea in
https://gitlab.gnome.org/GNOME/glib/commit/eb7b796bd206c31e336c89fb828a8a343ffb34ba
the inode/* mime types are not subclasses of application/octet-stream,
unlike all other mime types. The code is missing this check.
https://bugs.freedesktop.org/show_bug.cgi?id=100733
|
|
As noted by Colin in
https://gitlab.gnome.org/GNOME/glib/commit/2542b6f60492fadfb21f2c4a29976c3494c7e6c5
we must handle EINTR when calling open().
https://bugs.freedesktop.org/show_bug.cgi?id=100733
|
|
This just adds a missing free that Matthias noticed seven years ago in
https://gitlab.gnome.org/GNOME/glib/commit/83d34f630939aa13539e03895bef87da738c4127
https://bugs.freedesktop.org/show_bug.cgi?id=100733
|
|
Pointer arithmetic has an undefined behaviour under most compilers. This
wasn't a problem for us as we mostly targeted GCC, which has a defined
behaviour.
Quiet that warning by casting the pointer before doing operations on it.
https://bugs.webkit.org/show_bug.cgi?id=171026
https://bugs.freedesktop.org/show_bug.cgi?id=100733
|
|
Here we free data right before passing it to
_xdg_binary_or_text_fallback(), which is not good. This fix aligns the
code with _xdg_mime_cache_get_mime_type_for_file(), where it is
duplicated but without this bug.
This commit is based on a patch to Chromium's xdgmime from
https://codereview.chromium.org/1037023002
https://bugs.freedesktop.org/show_bug.cgi?id=100733
|
|
https://bugs.freedesktop.org/show_bug.cgi?id=100733
|
|
https://bugs.freedesktop.org/show_bug.cgi?id=100733
|
|
|
|
We were only checking 32 bytes into the file, which might not be enough
for some tar archives with long filenames.
https://bugs.freedesktop.org/show_bug.cgi?id=97372
|
|
|
|
|
|
As per http://tools.ietf.org/html/rfc2045#section-5.1
"
The type, subtype, and parameter names are not case sensitive. For
example, TEXT, Text, and TeXt are all equivalent top-level media
types.
"
https://bugs.freedesktop.org/show_bug.cgi?id=38415
|
|
|
|
To make it easier to populate the shared-mime-info test suite.
|
|
|
|
|
|
when resolving conflicting globs
|
|
|
|
|
|
Higher weight is more important, so return these first meaning
they will be used as the default.
|