summaryrefslogtreecommitdiff
path: root/src/fontfile
diff options
context:
space:
mode:
Diffstat (limited to 'src/fontfile')
-rw-r--r--src/fontfile/dirfile.c22
-rw-r--r--src/fontfile/fontfile.c43
-rw-r--r--src/fontfile/renderers.c4
3 files changed, 54 insertions, 15 deletions
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 a2fef2d..56d41d6 100644
--- a/src/fontfile/fontfile.c
+++ b/src/fontfile/fontfile.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: fontfile.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+/* $XdotOrg: xc/lib/font/fontfile/fontfile.c,v 1.1.4.3 2003/12/06 13:24:23 kaleb Exp $ */
/* $Xorg: fontfile.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
/*
@@ -26,7 +26,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
@@ -424,11 +424,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... */
@@ -499,6 +504,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)
@@ -534,6 +541,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);
@@ -873,10 +882,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:
@@ -981,10 +995,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);
}
}
diff --git a/src/fontfile/renderers.c b/src/fontfile/renderers.c
index 2db871d..0230e09 100644
--- a/src/fontfile/renderers.c
+++ b/src/fontfile/renderers.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/renderers.c,v 1.7 2002/12/09 17:30:00 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/renderers.c,v 1.8 2004/01/06 16:28:21 martin Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -58,7 +58,7 @@ FontFilePriorityRegisterRenderer (FontRendererPtr renderer, int priority)
if (rendererGeneration != serverGeneration) {
rendererGeneration = serverGeneration;
renderers.number = 0;
- if (!renderers.renderers)
+ if (renderers.renderers)
xfree(renderers.renderers);
renderers.renderers = NULL;
}