diff options
author | marha <marha@users.sourceforge.net> | 2012-03-05 09:59:38 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-03-05 09:59:38 +0100 |
commit | ffe218bbb0ffa6d2a7f7cbf6b1f81797e667183a (patch) | |
tree | 233b818e67de2073647e46e91ac688c6b43d5917 /libXfont/src/fontfile | |
parent | 15a500d3edb03668b43cc6898fafcda024d0f006 (diff) | |
download | vcxsrv-ffe218bbb0ffa6d2a7f7cbf6b1f81797e667183a.tar.gz vcxsrv-ffe218bbb0ffa6d2a7f7cbf6b1f81797e667183a.tar.bz2 vcxsrv-ffe218bbb0ffa6d2a7f7cbf6b1f81797e667183a.zip |
libfontenc xserver pixman mesa git update 5 Mar 2012
font-util-1.3.0
xclock-1.0.6
libXfont-1.4.5
inputproto-2.2
Diffstat (limited to 'libXfont/src/fontfile')
-rw-r--r-- | libXfont/src/fontfile/Makefile.in | 1 | ||||
-rw-r--r-- | libXfont/src/fontfile/decompress.c | 61 | ||||
-rw-r--r-- | libXfont/src/fontfile/fontdir.c | 16 |
3 files changed, 36 insertions, 42 deletions
diff --git a/libXfont/src/fontfile/Makefile.in b/libXfont/src/fontfile/Makefile.in index 5fbb70f9e..710b374de 100644 --- a/libXfont/src/fontfile/Makefile.in +++ b/libXfont/src/fontfile/Makefile.in @@ -105,6 +105,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BASE_CFLAGS = @BASE_CFLAGS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ diff --git a/libXfont/src/fontfile/decompress.c b/libXfont/src/fontfile/decompress.c index c8171dd4a..20971dfb9 100644 --- a/libXfont/src/fontfile/decompress.c +++ b/libXfont/src/fontfile/decompress.c @@ -44,7 +44,7 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ -/* +/* * decompress - cat a compressed file */ @@ -93,11 +93,11 @@ static char_type magic_header[] = { "\037\235" }; /* 1F 9D */ /* * the next two codes should not be changed lightly, as they must not * lie within the contiguous general code space. - */ + */ #define FIRST 257 /* first free entry */ #define CLEAR 256 /* table clear output code */ -#define STACK_SIZE 8192 +#define STACK_SIZE 65300 typedef struct _compressedFILE { BufFilePtr file; @@ -124,14 +124,6 @@ typedef struct _compressedFILE { } CompressedFile; -static int hsize_table[] = { - 5003, /* 12 bits - 80% occupancy */ - 9001, /* 13 bits - 91% occupancy */ - 18013, /* 14 bits - 91% occupancy */ - 35023, /* 15 bits - 94% occupancy */ - 69001 /* 16 bits - 95% occupancy */ -}; - static int BufCompressedClose ( BufFilePtr f, int doClose ); static int BufCompressedFill ( BufFilePtr f ); static code_int getcode ( CompressedFile *file ); @@ -142,7 +134,6 @@ BufFilePushCompressed (BufFilePtr f) { int code; int maxbits; - int hsize; CompressedFile *file; int extra; @@ -153,13 +144,12 @@ BufFilePushCompressed (BufFilePtr f) } code = BufFileGet (f); if (code == BUFFILEEOF) return 0; - + maxbits = code & BIT_MASK; - if (maxbits > BITS || maxbits < 12) + if (maxbits > BITS || maxbits <= INIT_BITS) return 0; - hsize = hsize_table[maxbits - 12]; extra = (1 << maxbits) * sizeof (char_type) + - hsize * sizeof (unsigned short); + (1 << maxbits) * sizeof (unsigned short); file = malloc (sizeof (CompressedFile) + extra); if (!file) return 0; @@ -178,14 +168,12 @@ BufFilePushCompressed (BufFilePtr f) file->tab_suffix[code] = (char_type) code; } file->free_ent = ((file->block_compress) ? FIRST : 256 ); + file->oldcode = -1; file->clear_flg = 0; file->offset = 0; file->size = 0; file->stackp = file->de_stack; bzero(file->buf, BITS); - file->finchar = file->oldcode = getcode (file); - if (file->oldcode != -1) - *file->stackp++ = file->finchar; return BufFileCreate ((char *) file, BufCompressedFill, 0, @@ -230,51 +218,56 @@ BufCompressedFill (BufFilePtr f) if (buf == bufend) break; - if (oldcode == -1) - break; - code = getcode (file); if (code == -1) break; - + if ( (code == CLEAR) && file->block_compress ) { for ( code = 255; code >= 0; code-- ) file->tab_prefix[code] = 0; file->clear_flg = 1; - file->free_ent = FIRST - 1; - if ( (code = getcode (file)) == -1 ) /* O, untimely death! */ - break; + file->free_ent = FIRST; + oldcode = -1; + continue; } incode = code; /* * Special case for KwKwK string. */ if ( code >= file->free_ent ) { + if ( code > file->free_ent || oldcode == -1 ) { + /* Bad stream. */ + return BUFFILEEOF; + } *stackp++ = finchar; code = oldcode; } - + /* + * The above condition ensures that code < free_ent. + * The construction of tab_prefixof in turn guarantees that + * each iteration decreases code and therefore stack usage is + * bound by 1 << BITS - 256. + */ + /* * Generate output characters in reverse order */ while ( code >= 256 ) { - if (stackp - de_stack >= STACK_SIZE - 1) - return BUFFILEEOF; *stackp++ = file->tab_suffix[code]; code = file->tab_prefix[code]; } finchar = file->tab_suffix[code]; *stackp++ = finchar; - + /* * Generate the new entry. */ - if ( (code=file->free_ent) < file->maxmaxcode ) { + if ( (code=file->free_ent) < file->maxmaxcode && oldcode != -1) { file->tab_prefix[code] = (unsigned short)oldcode; file->tab_suffix[code] = finchar; file->free_ent = code+1; - } + } /* * Remember previous code. */ @@ -382,7 +375,7 @@ static int BufCompressedSkip (BufFilePtr f, int bytes) { int c; - while (bytes--) + while (bytes--) { c = BufFileGet(f); if (c == BUFFILEEOF) @@ -397,7 +390,7 @@ main (int argc, char *argv[]) { BufFilePtr inputraw, input, output; int c; - + inputraw = BufFileOpenRead (0); input = BufFilePushCompressed (inputraw); output = BufFileOpenWrite (1); diff --git a/libXfont/src/fontfile/fontdir.c b/libXfont/src/fontfile/fontdir.c index e052bb371..97b2ba3b1 100644 --- a/libXfont/src/fontfile/fontdir.c +++ b/libXfont/src/fontfile/fontdir.c @@ -43,7 +43,7 @@ in this Software without prior written authorization from The Open Group. Bool FontFileInitTable (FontTablePtr table, int size) { - if (size < 0 || (size > INT32_MAX/sizeof(FontEntryRec))) + if (size < 0 || (size > INT32_MAX/sizeof(FontEntryRec))) return FALSE; if (size) { @@ -102,12 +102,12 @@ FontFileFreeTable (FontTablePtr table) } FontDirectoryPtr -FontFileMakeDir(char *dirName, int size) +FontFileMakeDir(const char *dirName, int size) { FontDirectoryPtr dir; int dirlen; int needslash = 0; - char *attrib; + const char *attrib; int attriblen; #if !defined(WIN32) @@ -279,7 +279,7 @@ FontFileSortDir(FontDirectoryPtr dir) #define isDigit(c) (XK_0 <= (c) && (c) <= XK_9) static int -SetupWildMatch(FontTablePtr table, FontNamePtr pat, +SetupWildMatch(FontTablePtr table, FontNamePtr pat, int *leftp, int *rightp, int *privatep) { int nDashes; @@ -438,7 +438,7 @@ FontFileSaveString (char *s) } FontEntryPtr -FontFileFindNameInScalableDir(FontTablePtr table, FontNamePtr pat, +FontFileFindNameInScalableDir(FontTablePtr table, FontNamePtr pat, FontScalablePtr vals) { int i, @@ -491,7 +491,7 @@ FontFileFindNameInDir(FontTablePtr table, FontNamePtr pat) } int -FontFileFindNamesInScalableDir(FontTablePtr table, FontNamePtr pat, int max, +FontFileFindNamesInScalableDir(FontTablePtr table, FontNamePtr pat, int max, FontNamesPtr names, FontScalablePtr vals, int alias_behavior, int *newmax) { @@ -578,7 +578,7 @@ FontFileFindNamesInScalableDir(FontTablePtr table, FontNamePtr pat, int max, } int -FontFileFindNamesInDir(FontTablePtr table, FontNamePtr pat, +FontFileFindNamesInDir(FontTablePtr table, FontNamePtr pat, int max, FontNamesPtr names) { return FontFileFindNamesInScalableDir(table, pat, max, names, @@ -767,7 +767,7 @@ FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName) extra->defaults.y = 75; } } - else + else { extra->defaults.x = vals.x; extra->defaults.y = vals.y; |