summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-05-05test-mime-data: output errors to stderrfix/test-mime-data-stderrVille Skyttä1-7/+7
2022-03-30ci: Test meson buildBastien Nocera1-1/+15
2022-03-30build: Add meson supportEli Schwartz2-0/+52
This will allow using the xdgmime test programs as a meson subproject.
2022-03-30ci: Fix shared-mime-info test not exercising our buildEli Schwartz1-1/+1
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.
2022-01-19xdgmimemagic: Fix unused variable warning when !LITTLE_ENDIANPablo Correa Gómez1-0/+2
2021-12-13Fix segfaults due to strict ISO C99 mode enforcementStefan Brüns3-1/+3
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.
2021-10-26Makefile: Add support for POSIX makeIssam E. Maghni1-5/+13
2021-10-11test-mime-data: fail when an error occursIgor Kushnir1-17/+10
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.
2021-10-07add OOM handling in mimemagicEgor Bychin1-0/+12
2021-09-28Silence an uninitialize variable warningMatthias Clasen1-0/+1
2021-09-27xdgmime: Call xdg_mime_init() before xdg_mime_list_mime_parents()Philip Withnall1-0/+2
Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #9
2021-04-13Remove function pointer casts when calling xdg_run_command_on_dirs().Daniel Cheng1-6/+6
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.
2021-03-18Fix fd leak in error pathKamil Dudka2-0/+2
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|
2021-01-06ci: Add CIBastien Nocera1-0/+29
2021-01-04Fix signedness warnings in src/xdgmimecache.cEmmanuel Fleury1-3/+4
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++) | ^
2021-01-04Fix signedness warnings in ↵Emmanuel Fleury1-1/+2
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++) | ^
2021-01-04Fix signedness warning in ↵Emmanuel Fleury1-1/+2
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++) | ^
2021-01-04Fix signedness warning in src/xdgmimecache.c:cache_glob_node_lookup_suffix()Emmanuel Fleury1-1/+2
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) | ^
2021-01-04Fix signedness warning in rc/xdgmimecache.c:cache_glob_lookup_fnmatch()Emmanuel Fleury1-1/+2
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++) | ^
2021-01-04Fix signedness warning in src/xdgmimecache.c:cache_magic_compare_to_data()Emmanuel Fleury1-2/+2
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++) | ^
2021-01-04Fix signedness warning in src/xdgmimecache.c:cache_magic_matchlet_compare()Emmanuel Fleury1-1/+1
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++) | ^
2021-01-04Fix signedness warnings in ↵Emmanuel Fleury1-1/+1
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++) | ^
2021-01-04Fix signedness warnings in ↵Emmanuel Fleury1-1/+1
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++) | ^
2021-01-04Fix signedness warnings in src/xdgmimemagic.c:_xdg_mime_magic_parse_magic_line()Emmanuel Fleury1-5/+5
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) | ^
2021-01-04Fix signedness warning in src/xdgmimeint.cEmmanuel Fleury1-1/+1
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) | ^
2020-12-30Fix fallback after multiple matching globsDavid Faure2-26/+10
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
2020-12-27Fix usage information for print-mime-dataDavid Faure1-2/+2
2019-06-03xdgmime: Don’t set an out argument if it’s NULLPhilip Withnall1-1/+2
See https://gitlab.gnome.org/GNOME/glib/merge_requests/733.
2018-11-19Comment grammar fixVille Skyttä1-1/+1
2018-07-17Fix buffer underflow in __gio_xdg_cache_mime_type_subclass()Michael Catanzaro2-10/+28
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
2018-07-17Fix special case for mime_type_subclassMichael Catanzaro2-2/+4
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
2018-07-17Handle EINTR in open()Michael Catanzaro1-1/+4
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
2018-07-17Don't forget to free resources on an early returnMichael Catanzaro1-1/+4
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
2018-07-17Fix void pointer arithmetic in cache_magic_matchlet_compare_to_data()Michael Catanzaro1-1/+1
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
2018-07-17Fix use after free in xdg_mime_get_mime_type_for_fileMichael Catanzaro1-4/+4
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
2018-07-17Add space before paren in _xdg_mime_cache_get_mime_type_for_fileMichael Catanzaro1-1/+1
https://bugs.freedesktop.org/show_bug.cgi?id=100733
2018-07-16build: Add a .gitignoreMichael Catanzaro1-0/+4
https://bugs.freedesktop.org/show_bug.cgi?id=100733
2018-06-17Spelling fixesVille Skyttä2-2/+2
2017-09-05Check further into the file whether it is text or binaryBastien Nocera1-1/+1
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
2013-01-07tests: Fix current test-mime failuresBastien Nocera1-3/+3
2013-01-07tests: Make test-mime failures fatalBastien Nocera1-2/+7
2013-01-07tests: Mime-types are not case-sensitiveBastien Nocera2-2/+2
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
2012-09-27Ignore non-regular files in print-mime-dataBastien Nocera1-0/+15
2012-09-25Add print-mime-data programBastien Nocera2-2/+175
To make it easier to populate the shared-mime-info test suite.
2011-10-29Do case-insensitive checks for fnmatch-type-matching too.David Faure1-10/+16
2011-10-28It's faster and simpler to just use memcmp here.David Faure1-9/+2
2011-10-24Fix xdgmime bug #18109: implement better use of magic resultDavid Faure1-3/+14
when resolving conflicting globs
2011-10-06Fix filename in #warning messageDavid Faure1-1/+1
2011-09-29Implement text vs binary fallback; support for application/x-zerosizeDavid Faure5-7/+42
2009-10-08sort glob hits with larger weight firstAlexander Larsson2-2/+2
Higher weight is more important, so return these first meaning they will be used as the default.