FcLangSetIndex() contains code like this:
low = fcLangCharSetRanges[firstChar - 'a'].begin;
high = fcLangCharSetRanges[firstChar - 'a'].end;
/* no matches */
if (low > high)
The assumption behind this test didn't hold before this commit, unless
there is at least one language name that starts with 'z' (which is
thankfully the case in our world :-). If the last language name in
lexicographic order starts for instance with 'x', this change ensures
that fcLangCharSetRanges['y' - 'a'].begin and
fcLangCharSetRanges['z' - 'a'].begin
are equal to NUM_LANG_CHAR_SET, in order to make the above assumption
correct in all cases.
Code currently returns a fatal error if it tries to add more entries
than the array has room for, but it wasn't checking to make sure
the final null terminator entry would fit.
Reported by parfait 1.3:
Error: Buffer overrun
Buffer overflow (CWE 120): In array dereference of files[i] with index i
Array size is 256 elements (of 4 bytes each), index >= 0 and index <= 256
at line 250 of fc-glyphname/fc-glyphname.c in function 'main'.
Error: Buffer overrun
Buffer overflow (CWE 120): In array dereference of entries[i] with index i
Array size is 1024 elements (of 8 bytes each), index >= 0 and index <= 1024
at line 298 of fc-lang/fc-lang.c in function 'main'.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Fontconfig assigns an index number to each language it knows about.
The index is used to index a bit in FcLangSet language map. The bit
map is stored in the cache.
Previously fc-lang simply sorted the list of languages and assigned
them an index starting from zero. Net effect is that whenever new
orth files were added, all the FcLangSet info in the cache files would
become invalid. This was causing weird bugs like this one:
https://bugzilla.redhat.com/show_bug.cgi?id=490888
With this commit we fix the index assigned to each language. The index
will be based on the order the orth files are passed to fc-lang. As a
result all orth files are explicitly listed in Makefile.am now, and
new additions should be made to the end of the list. The list is made
to reflect the sorted list of orthographies from 2.6.0 released followed
by new additions since.
This fixes the stability problem. Needless to say, recreating caches
is necessary before any new orthography is recognized in existing fonts,
but at least the existing caches are still valid and don't cause bugs
like the above.
Using a simple shell script that processes the public headers, two header
files are constructed that map public symbols to hidden internal aliases
avoiding the assocated PLT entry for referring to a public symbol.
A few mistakes in the FcPrivate/FcPublic annotations were also discovered
through this process
Charset freezer api now uses allocated object. Also required minor fixes to
charset freezer code to remove assumption that all input charsets are
persistant.
Pagesize no longer matters in architecture decisions, the entire cache file
is mmaped into the library. However, lots of intptr_t values are in use now,
so that value is important.
fc-lang now requires fcserialize.c, which has been added to the repository.
Replace all of the bank/id pairs with simple offsets, recode several
data structures to always use offsets inside the library to avoid
conditional paths. Exposed data structures use pointers to hold offsets,
setting the low bit to distinguish between offset and pointer.
Use offset-based data structures for lang charset encodings; eliminates
separate data structure format for that file.
Much testing will be needed; offsets are likely not detected everywhere in
the library yet.
(numbers_count); didn't strip duplicate numbers (langBankNumbers); and
leafidx_offset and numbers_offset in fcLangCharSets are wrong.
Removed leafidx_count and numbers_count since they are the same and
replaced them with offset_count.
reviewed by: plam
and distribute bytes for each directory from a single malloc for that
directory. Store pointers as differences between the data pointed to
and the pointer's address (s_off = s - v). Don't serialize data
structures that never actually get serialized. Separate strings used
for keys from strings used for values (in FcPatternElt and FcValue,
respectively). Bump FC_CACHE_VERSION to 2.
cache. Add *Read and *Write procedures which mmap in and write out the
fontconfig data structures to disk. Currently, create cache in /tmp,
with different sections for each architecture (as returned by uname's
.machine field. Run the fc-cache binary to create a new cache file;
fontconfig then uses this cache file on subsequent runs, saving lots of
memory. Also fixes a few bugs and leaks.
This patch allows the fundamental fontconfig data structures to be
serialized. I've converted everything from FcPattern down to be able to
use *Ptr objects, which can be either static or dynamic (using a union
which either contains a pointer or an index) and replaced storage of
pointers in the heap with the appropriate *Ptr object. I then changed
all writes of pointers to the heap with a *CreateDynamic call, which
creates a dynamic Ptr object pointing to the same object as before.
This way, the fundamental fontconfig semantics should be unchanged; I
did not have to change external signatures this way, although I did
change some internal signatures. When given a *Ptr object, just run *U
to get back to a normal pointer; it gives the right answer regardless
of whether we're using static or dynamic storage.
I've also implemented a Fc*Serialize call. Calling FcFontSetSerialize
converts the dynamic FcFontSets contained in the config object to
static FcFontSets and also converts its dependencies (e.g. everything
you'd need to write to disk) to static objects. Note that you have to
call Fc*PrepareSerialize first; this call will count the number of
objects that actually needs to be allocated, so that we can avoid
realloc. The Fc*Serialize calls then check the static pointers for
nullness, and allocate the buffers if necessary. I've tested the
execution of fc-list and fc-match after Fc*Serialize and they appear to
work the same way.
clean up .spec file; perhaps this will be useful to somebody...
Update to 2.2.93
Make 'scanopen' static so GCC doesn't whine about lacking prototype
Add WARN_CFLAGS to pass -W flags for GCC systems
Change various char types around to match across function calls. Fixed bug
in using available_sizes[i].height which is in pixels, not 64ths of a
pixel.
but there are still failures long into the process dealing with docs
(as always).
The big changes here are mostly to make $(srcdir) != "." work correctly,
fixing the docbook related sections and fc-lang were particularily
tricky. Docbook refuses to load system entities from anywhere other
than where the original .sgml file was located, so no luck looking in
"." for the configure-generated version.sgml and confdir.sgml files.
fc-lang needed help finding .orth files; added a -d option to set the
directory as the least evil of many options.
Now to go use a faster machine and try and wring out the last issues.
funcs into fc-lang, which was done by refactoring code in fccharset.c
and fcfreetype.c a bit
Updated ethiopic orthographies
Remove imake support
Install empty local.conf file if none is present