Commit Graph

1196 Commits

Author SHA1 Message Date
Akira TAGOH 98099ffc9f Ifdef'ed unnecessary code for Win32
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/147
2019-03-22 07:47:33 +00:00
Robert Yang 586e35450e src/fccache.c: Fix define for HAVE_POSIX_FADVISE
Otherwise, there would be build errors in the following 2 cases:
* define HAVE_POSIX_FADVISE
Or:
* undef HAVE_POSIX_FADVISE

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
2019-01-25 03:48:26 +00:00
Akira TAGOH 699d6e4d84 Fix a crash with invalid matrix element
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/140
2019-01-23 05:59:34 +00:00
Akira TAGOH b047e29954 Fix a dereference of a null pointer
When exiting from for loop by not satisfying the condition of `(s = next[i])` at FcCacheRemoveUnlocked()
referring s->alloated will be invalid.
2018-11-30 10:42:26 +00:00
Akira TAGOH a57647e155 covscan fix: get rid of unnecessary condition check 2018-11-30 07:41:16 +00:00
Akira TAGOH 65c7427c01 Warn when constant name is used for unexpected object
This fixes the sort of weird things like `fc-match :size=rgb` done without any errors.
This might be annoyed but the error messages should helps to fix an application bug or
suggest more useful constant names to fontconfig.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/137
2018-11-30 07:04:22 +00:00
Akira TAGOH 9d5149ac41 Fix FcFontList doesn't return a font with FC_COLOR=true
"color" property has a value more than 1 because the value of FT_HAS_COLOR
is directly set to it. this seems breaking the behavior of FcFontList with FC_COLOR=true
because it is more than FcDontCare.

So changing comparison that way.
2018-11-27 09:39:15 +00:00
Akira TAGOH 648e0cf3d5 Use FC_PATH_MAX instead of PATH_MAX
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/131
2018-11-06 16:33:03 +09:00
Behdad Esfahbod f7036d589b Fix name-table language code mapping for Mongolian 2018-10-25 07:31:44 +00:00
Keith Packard 5f12f564f8 Do not remove UUID file when a scanned directory is empty
Because FcDirCacheDeleteUUID does not reset the modification time on
the directory, and because FcDirCacheRead unconditionally creates the
UUID file each time it is run, any empty directory in the cache will
get its timestamp changed each time the cache for that directory is
read.

Instead, just leave the UUID file around as it is harmless.

The alternative would be to only create the UUID file after the cache
has been created and the directory has been discovered to be
non-empty, but that would delay the creation of the UUID file.

Signed-off-by: Keith Packard <keithp@keithp.com>
2018-10-25 16:02:55 +09:00
Akira TAGOH 5f5ec5676c Do not try updating mtime when unlink was failed 2018-10-05 02:32:09 +00:00
Akira TAGOH ff5b49be2b Do not update mtime when removing .uuid file
This avoids a situation triggers updating caches on a directory where .uuid file was removed.

Resolves: https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/107
2018-10-05 02:32:07 +00:00
Akira TAGOH e4788c5a96 add missing the case of prefix="default" as documented 2018-10-04 08:07:09 +00:00
Akira TAGOH 1aa8b700c3 Add more prefix support in <dir> element
Added two prefix modes:
  "relative" that makes the relative path be relative to current file
  "cwd" for relative to current working directory which implies current behavior.

Resolves: https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/15
2018-10-02 10:12:14 +00:00
Akira TAGOH 806fd4c2c5 Fix the issue that '~' wasn't extracted to the proper homedir
'~' in the filename was extracted to the home directory name in FcConfigFilename() though,
this behavior was broken by d1f48f11. this change fixes it back to the correct behavior.

https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/110
2018-09-04 09:55:20 +00:00
Akira TAGOH 8208f99fa1 Fix the build issue with --enable-static
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/109
2018-09-03 07:24:42 +00:00
Akira TAGOH ddeec818cc Fix missing closing bracket in FcStrIsAbsoluteFilename()
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/96
2018-08-21 03:08:58 +00:00
Akira TAGOH a1efb5ea8c Fix the build issue with gperf
GPerf seems not allowing the empty lines though, current recipes are supposed to drop them.
but seems not working on some env.
So taking the proper way to do that instead of incompatible things against platforms.
2018-08-01 08:10:35 +00:00
Tom Anderson 1451f829e7 Fix build with CFLAGS="-std=c11 -D_GNU_SOURCE" 2018-07-26 02:57:07 +00:00
Akira TAGOH 9f1b92f27f Fix memory leak 2018-07-25 13:41:47 +09:00
Akira TAGOH 5b277806df Drop the redundant code
"value == FcTypeInteger" won't be true because it was converted to FcTypeDouble earlier
2018-07-25 12:44:38 +09:00
Akira TAGOH a1ad5fe2ba Allocate sufficient memory to terminate with null 2018-07-25 12:40:17 +09:00
Akira TAGOH 5ea2ab6a38 Make a call fail on ENOMEM 2018-07-25 12:39:53 +09:00
Akira TAGOH 38569f2f2e Fix allocating insufficient memory for terminating null of the string 2018-07-19 08:31:59 +00:00
Akira TAGOH b1762935c3 Fix possibly dereferencing a null pointer 2018-07-19 08:31:14 +00:00
Akira TAGOH 8e97d745cc Fix a typo 2018-07-19 08:21:33 +00:00
Akira TAGOH efac784b01 Fix dereferencing null pointer 2018-07-19 07:55:40 +00:00
Akira TAGOH 1ac2218467 do not pass null pointer to memcpy 2018-07-19 07:50:20 +00:00
Akira TAGOH f3981a8bcd Fix access in a null pointer dereference 2018-07-19 16:44:03 +09:00
Akira TAGOH 586ac3b6c0 Fix array access in a null pointer dereference
FcFontSetFont() accesses fs->fonts in that macro though, there was no error checks
if it is null or not.
As a result, there was a code path that it could be a null.
Even though this is unlikely to see in usual use, it might be intentionally created
in a cache.

So if fs->fonts is a null, we should consider a cache is invalid.
2018-07-19 07:09:39 +00:00
Akira TAGOH 51afd09d62 Fix unterminated string issue 2018-07-19 05:51:02 +00:00
Akira TAGOH 37c9c16dad Fix memory leak 2018-07-19 04:29:01 +00:00
Akira TAGOH 433718fb77 Fix memory leak 2018-07-19 04:17:21 +00:00
Akira TAGOH eafa931ff9 Fix memory leak 2018-07-19 03:15:01 +00:00
Akira TAGOH 12be797387 Fix memory leaks 2018-07-19 03:14:58 +00:00
Akira TAGOH 4b1276e240 Fix memory leak 2018-07-19 03:14:54 +00:00
Akira TAGOH e9d3177557 Fix the leak of file handle 2018-07-19 11:32:50 +09:00
Tom Anderson d1f48f11d5 Return canonicalized paths from FcConfigRealFilename
FcConfigRealFilename() follows symlinks, but the link may be relative to the
directory containing the link.  For example, on my system, I have this file:

/etc/fonts/conf.d/99-language-selector-zh.conf ->
    ../conf.avail/99-language-selector-zh.conf

Since /etc/fonts/conf.d is probably not in PATH, open()ing the file would fail.
This change makes FcConfigRealFilename() return the canonicalized filename
instead.  So for the example above, it would return:

/etc/fonts/conf.avail/99-language-selector-zh.conf

This was causing bad font rendering in Chromium [1] after the regression I
introduced in 7ad010e80b.

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=857511
2018-07-16 18:00:35 +02:00
Behdad Esfahbod 48e9e5f4f0 Use FT_HAS_COLOR 2018-07-16 17:59:54 +02:00
Matthieu Herrb 5a46d572c0 FcCacheFindByStat(): fix checking of nanoseconds field. 2018-07-10 12:27:16 +09:00
Tom Anderson 6cc99d6a82 Fix heap use-after-free 2018-06-13 17:05:54 +09:00
Akira TAGOH f5dd8512bd Remove .uuid when no font files exists on a directory
https://bugs.freedesktop.org/show_bug.cgi?id=106632
2018-06-11 17:03:46 +09:00
Tom Anderson 096e8019be Fix CFI builds
CFI [1] is a dynamic analysis tool that checks types at runtime.  It reports an
error when using a function with signature eg. (void (*)(char*)) as
(void (*)(void*)).  This change adds some wrapper functions to avoid this issue.
In optimized builds, the functions should get optimized away.

[1] https://clang.llvm.org/docs/ControlFlowIntegrity.html
2018-06-11 16:02:57 +09:00
Akira TAGOH 14c23a5715 Fix double-free 2018-05-25 15:20:10 +09:00
Alexander Larsson 3ea70f9368 Cache: Remove alias_table
There is really no need for this anymore

https://bugs.freedesktop.org/show_bug.cgi?id=106618
2018-05-25 14:43:06 +09:00
Alexander Larsson c42402d0b8 Cache: Rewrite relocated paths in earlier
This changes the rewriting of the FC_FILE values for relocated caches to an earlier stage
while reading the cache. This is better, because it means all APIs will report the
rewritten paths, not just the once that use the list apis.

We do this by detecting the relocated case and duplicating the FcPattern and FcPatternElm
in an cache allocation (which will die with the cache) and then reusing the FcValueLists
from the cache.

This means that in the rewritten case we will use some more memory, but not the full
size of the cache. In a test here I had 800k of relocated caches, but ~200k of wasted
on duplicating the objects.

This should fix https://bugs.freedesktop.org/show_bug.cgi?id=106618
2018-05-25 14:42:52 +09:00
Alexander Larsson a63b9c622e Add FcCacheAllocate() helper
This lets you allocate a chunk of memory that will be freed when the cache
is freed.

https://bugs.freedesktop.org/show_bug.cgi?id=106618
2018-05-25 14:42:05 +09:00
Akira TAGOH 94080c3d48 Fix -Wstringop-truncation warning 2018-05-25 14:02:58 +09:00
Akira TAGOH 684c3ce685 Fix leaks 2018-05-25 13:51:10 +09:00
Chris Lamb f098adac54 Ensure cache checksums are deterministic
Whilst working on the Reproducible Builds[0] effort, we noticed that
fontconfig generates unreproducible cache files.

This is due to fc-cache uses the modification timestamps of each
directory in the "checksum" and "checksum_nano" members of the _FcCache
struct. This is so that it can identify which cache files are valid
and/or require regeneration.

This patch changes the behaviour of the checksum calculations to prefer
the value of the SOURCE_DATE_EPOCH[1] environment variable over the
directory's own mtime. This variable can then be exported by build
systems to ensure reproducible output.

If SOURCE_DATE_EPOCH is not set or is newer than the mtime of the
directory, the existing behaviour is unchanged.

This work was sponsored by Tails[2].

 [0] https://reproducible-builds.org/
 [1] https://reproducible-builds.org/specs/source-date-epoch/
 [2] https://tails.boum.org/
2018-05-16 16:06:46 +09:00