Bail gracefully if the cache file does not contain enough data.

This commit is contained in:
Patrick Lam 2006-04-19 16:17:19 +00:00
parent a77572948e
commit c001a192af
5 changed files with 46 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2006-04-19 Patrick Lam <plam@mit.edu>
* src/fccache.c (FcDirCacheConsume, FcCacheNextOffset):
Bail gracefully if the cache file does not contain enough data.
2006-04-14 Patrick Lam <plam@mit.edu>
* fonts.conf.in:

23
README
View File

@ -1,11 +1,30 @@
Fontconfig
Font configuration and customization library
Version 2.3.94
2006-02-24
Version 2.3.95
2006-04-18
Check INSTALL for compilation and installation instructions.
Report bugs to https://bugs.freedesktop.org in the fontconfig module.
2.3.95
Match 'Standard Symbols L' for 'Symbol'. Add URW fonts as aliases for
all of the PostScript fonts. (reported by Miguel Rodriguez). Fix a
number of Coverity defects (Frederic Crozat). Speed up FcFontSort
(fix suggested by Kenichi Handa). Fix error with charsets. Survive
missing docbook2pdf. Compile on HP-UX, AIX, SGI and Windows (Cygwin,
MinGW). Fix intel compiler warnings. Fix multiarch support (don't
destroy multiarch files!) Require pkg-config. (Thanks Behdad; better
solution wanted for libxml2 detection!) Fix typos in orth files and
add orth for Lingala (reported by Denis Jacquerye). Remove debian/
directory. Add a configuration file that disables hinting for the
Lohit Gujarati font (since the hinting distorts some glyphs quite
badly). Sort directory entries while scanning them from disk;
prevents Heisenbugs due to file ordering in a directory (due to Egmont
Koblinger). Fix Wine's problem with finding fonts. (Reported by
Bernhard Rosenkraenzer.)
2.3.94
fc-cat can take directories as input and creates old-style fonts.cache

View File

@ -33,7 +33,7 @@ dnl This is the package version number, not the shared library
dnl version. This same version number must appear in fontconfig/fontconfig.h
dnl Yes, it is a pain to synchronize version numbers. Unfortunately, it's
dnl not possible to extract the version number here from fontconfig.h
AM_INIT_AUTOMAKE(fontconfig, 2.3.94)
AM_INIT_AUTOMAKE(fontconfig, 2.3.95)
AM_MAINTAINER_MODE
dnl libtool versioning

View File

@ -46,7 +46,7 @@ typedef int FcBool;
#define FC_MAJOR 2
#define FC_MINOR 3
#define FC_REVISION 94
#define FC_REVISION 95
#define FC_VERSION ((FC_MAJOR * 10000) + (FC_MINOR * 100) + (FC_REVISION))

View File

@ -617,6 +617,10 @@ static int
FcCacheNextOffset(off_t w)
{
static long pagesize = -1;
if (w == -1)
return w;
if (pagesize == -1)
#if defined (HAVE_SYSCONF)
pagesize = sysconf(_SC_PAGESIZE);
@ -1164,7 +1168,7 @@ FcDirCacheConsume (int fd, const char * dir, FcFontSet *set, FcConfig *config)
{
FcCache metadata;
void * current_dir_block;
off_t pos;
off_t pos, endpos;
if (read(fd, &metadata, sizeof(FcCache)) != sizeof(FcCache))
return FcFalse;
@ -1181,6 +1185,19 @@ FcDirCacheConsume (int fd, const char * dir, FcFontSet *set, FcConfig *config)
}
pos = FcCacheNextOffset (lseek(fd, 0, SEEK_CUR));
/* This is not failsafe (multi-arches can break it),
* but fd has got to have at least as many bytes as
* metadata.count, or something's going to go horribly wrong. */
if (pos == (off_t)-1)
return FcFalse;
endpos = lseek (fd, 0, SEEK_END);
if (endpos == (off_t)-1 || endpos - pos < metadata.count)
return FcFalse;
if (lseek (fd, pos, SEEK_SET) == -1)
return FcFalse;
#if defined(HAVE_MMAP) || defined(__CYGWIN__)
current_dir_block = mmap (0, metadata.count,
PROT_READ, MAP_SHARED, fd, pos);