From 45fc57ae316da51b2f9abab2aee303456730ab54 Mon Sep 17 00:00:00 2001 From: Kaleb Keithley Date: Mon, 23 Feb 2004 20:34:43 +0000 Subject: Import most of XFree86 4.4RC3. This import excludes files which have the new license. If we want to, later we can import 4.4RC3 again and pick up the files that have the new license, but for now the vendor branch is "pure." --- src/FreeType/ftfuncs.c | 14 +++++++++++--- src/Type1/t1funcs.c | 8 ++++++-- src/fontfile/dirfile.c | 22 +++++++++++++++++++++- src/fontfile/fontfile.c | 41 ++++++++++++++++++++++++++++++----------- 4 files changed, 68 insertions(+), 17 deletions(-) diff --git a/src/FreeType/ftfuncs.c b/src/FreeType/ftfuncs.c index 4dbff4a..556a511 100644 --- a/src/FreeType/ftfuncs.c +++ b/src/FreeType/ftfuncs.c @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/lib/font/FreeType/ftfuncs.c,v 1.42 2003/12/31 05:10:03 dawes Exp $ */ +/* $XFree86: xc/lib/font/FreeType/ftfuncs.c,v 1.43 2004/02/07 04:37:18 dawes Exp $ */ #include "fontmisc.h" @@ -1504,9 +1504,17 @@ FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info, i++; } - j = FTGetEnglishName(face->face, TT_NAME_ID_PS_NAME, + vp = (char *)FT_Get_Postscript_Name(face->face); + if (vp) { + j = strlen(vp); + } else { + j = -1; + } + if (j < 0) { + j = FTGetEnglishName(face->face, TT_NAME_ID_PS_NAME, val, MAXFONTNAMELEN); - vp = val; + vp = val; + } if (j < 0) { if(t1info && t1info->full_name) { vp = t1info->full_name; diff --git a/src/Type1/t1funcs.c b/src/Type1/t1funcs.c index 70da203..087c7e5 100644 --- a/src/Type1/t1funcs.c +++ b/src/Type1/t1funcs.c @@ -71,7 +71,7 @@ * The Original Software is CID font code that was developed by Silicon * Graphics, Inc. */ -/* $XFree86: xc/lib/font/Type1/t1funcs.c,v 3.33 2003/07/19 13:16:40 tsi Exp $ */ +/* $XFree86: xc/lib/font/Type1/t1funcs.c,v 3.34 2004/02/02 03:55:27 dawes Exp $ */ /* @@ -123,10 +123,14 @@ from The Open Group. #else #include "Xmd.h" #include "Xdefs.h" -#include "xf86_ansic.h" #endif #include "os.h" + +#ifdef FONTMODULE +#include "xf86_ansic.h" +#endif + #include "fntfilst.h" #include "fontutil.h" #include "FSproto.h" diff --git a/src/fontfile/dirfile.c b/src/fontfile/dirfile.c index bb7c339..b75042a 100644 --- a/src/fontfile/dirfile.c +++ b/src/fontfile/dirfile.c @@ -25,7 +25,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. */ -/* $XFree86: xc/lib/font/fontfile/dirfile.c,v 3.16 2003/04/07 16:23:31 eich Exp $ */ +/* $XFree86: xc/lib/font/fontfile/dirfile.c,v 3.18 2004/02/11 21:11:18 dawes Exp $ */ /* * Author: Keith Packard, MIT X Consortium @@ -68,6 +68,9 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir) FontDirectoryPtr dir = NullFontDirectory; + if (strlen(directory) + 1 + sizeof(FontDirFile) > sizeof(dir_file)) + return BadFontPath; + #ifdef FONTDIRATTRIB /* Check for font directory attributes */ #ifndef __UNIXOS2__ @@ -159,6 +162,9 @@ FontFileDirectoryChanged(FontDirectoryPtr dir) char dir_file[MAXFONTFILENAMELEN]; struct stat statb; + if (strlen(dir->directory) + sizeof(FontDirFile) > sizeof(dir_file)) + return FALSE; + strcpy (dir_file, dir->directory); strcat (dir_file, FontDirFile); if (stat (dir_file, &statb) == -1) @@ -207,6 +213,8 @@ AddFileNameAliases(FontDirectoryPtr dir) continue; len = strlen (fileName) - renderer->fileSuffixLen; + if (len >= sizeof(copy)) + continue; CopyISOLatin1Lowered (copy, fileName, len); copy[len] = '\0'; name.name = copy; @@ -256,9 +264,13 @@ ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir) int status = Successful; struct stat statb; + if (strlen(directory) >= sizeof(alias_file)) + return BadFontPath; dir = *pdir; strcpy(alias_file, directory); if (!isFile) { + if (strlen(directory) + 1 + sizeof(FontAliasFile) > sizeof(alias_file)) + return BadFontPath; if (directory[strlen(directory) - 1] != '/') strcat(alias_file, "/"); strcat(alias_file, FontAliasFile); @@ -291,6 +303,10 @@ ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir) status = AllocError; break; case NAME: + if (strlen(lexToken) >= sizeof(alias)) { + status = BadFontPath; + break; + } strcpy(alias, lexToken); token = lexAlias(file, &lexToken); switch (token) { @@ -307,6 +323,10 @@ ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir) status = AllocError; break; case NAME: + if (strlen(lexToken) >= sizeof(font_name)) { + status = BadFontPath; + break; + } CopyISOLatin1Lowered(alias, alias, strlen(alias)); CopyISOLatin1Lowered(font_name, lexToken, strlen(lexToken)); if (!FontFileAddFontAlias (dir, alias, font_name)) diff --git a/src/fontfile/fontfile.c b/src/fontfile/fontfile.c index a0323be..22f844f 100644 --- a/src/fontfile/fontfile.c +++ b/src/fontfile/fontfile.c @@ -25,7 +25,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. */ -/* $XFree86: xc/lib/font/fontfile/fontfile.c,v 3.21 2003/12/02 19:50:40 dawes Exp $ */ +/* $XFree86: xc/lib/font/fontfile/fontfile.c,v 3.22 2004/02/11 21:11:20 dawes Exp $ */ /* * Author: Keith Packard, MIT X Consortium @@ -423,11 +423,16 @@ FontFileOpenFont (pointer client, FontPathElementPtr fpe, Mask flags, vals.ranges = ranges; vals.nranges = nranges; - strcpy (fileName, dir->directory); - strcat (fileName, scalable->fileName); - ret = (*scalable->renderer->OpenScalable) (fpe, pFont, + if (strlen(dir->directory) + strlen(scalable->fileName) >= + sizeof(fileName)) { + ret = BadFontName; + } else { + strcpy (fileName, dir->directory); + strcat (fileName, scalable->fileName); + ret = (*scalable->renderer->OpenScalable) (fpe, pFont, flags, entry, fileName, &vals, format, fmask, non_cachable_font); + } /* In case rasterizer does something bad because of charset subsetting... */ @@ -498,6 +503,8 @@ FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont, bitmap = &entry->u.bitmap; if(!bitmap || !bitmap->renderer->OpenBitmap) return BadFontName; + if (strlen(dir->directory) + strlen(bitmap->fileName) >= sizeof(fileName)) + return BadFontName; strcpy (fileName, dir->directory); strcat (fileName, bitmap->fileName); ret = (*bitmap->renderer->OpenBitmap) @@ -533,6 +540,8 @@ FontFileGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo, bitmap = &entry->u.bitmap; if (!bitmap || !bitmap->renderer->GetInfoBitmap) return BadFontName; + if (strlen(dir->directory) + strlen(bitmap->fileName) >= sizeof(fileName)) + return BadFontName; strcpy (fileName, dir->directory); strcat (fileName, bitmap->fileName); ret = (*bitmap->renderer->GetInfoBitmap) (fpe, pFontInfo, entry, fileName); @@ -872,10 +881,15 @@ FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe, bc = &entry->u.bc; entry = bc->entry; /* Make a new scaled instance */ - strcpy (fileName, dir->directory); - strcat (fileName, scalable->fileName); - ret = (*scalable->renderer->GetInfoScalable) + if (strlen(dir->directory) + strlen(scalable->fileName) >= + sizeof(fileName)) { + ret = BadFontName; + } else { + strcpy (fileName, dir->directory); + strcat (fileName, scalable->fileName); + ret = (*scalable->renderer->GetInfoScalable) (fpe, *pFontInfo, entry, tmpName, fileName, &bc->vals); + } break; #endif default: @@ -980,10 +994,15 @@ FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe, vals.nranges = nranges; /* Make a new scaled instance */ - strcpy (fileName, dir->directory); - strcat (fileName, scalable->fileName); - ret = (*scalable->renderer->GetInfoScalable) - (fpe, *pFontInfo, entry, &tmpName, fileName, &vals); + if (strlen(dir->directory) + strlen(scalable->fileName) >= + sizeof(fileName)) { + ret = BadFontName; + } else { + strcpy (fileName, dir->directory); + strcat (fileName, scalable->fileName); + ret = (*scalable->renderer->GetInfoScalable) + (fpe, *pFontInfo, entry, &tmpName, fileName, &vals); + } if (ranges) xfree(ranges); } } -- cgit v1.2.3