rpms/fontconfig/devel fontconfig-fontsubdir-parse-fix.patch, NONE, 1.1 fontconfig-memleak-fix.patch, NONE, 1.1 fontconfig-misc-warning-fixes.patch, NONE, 1.1 fontconfig-seife-crash.patch, NONE, 1.1 fontconfig.spec, 1.61, 1.62

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Thu Feb 2 15:07:29 UTC 2006


Author: mclasen

Update of /cvs/dist/rpms/fontconfig/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv17157

Modified Files:
	fontconfig.spec 
Added Files:
	fontconfig-fontsubdir-parse-fix.patch 
	fontconfig-memleak-fix.patch 
	fontconfig-misc-warning-fixes.patch 
	fontconfig-seife-crash.patch 
Log Message:
Accumulated fixes


fontconfig-fontsubdir-parse-fix.patch:
 fccfg.c |   82 ++++++++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 54 insertions(+), 28 deletions(-)

--- NEW FILE fontconfig-fontsubdir-parse-fix.patch ---
--- src/fccfg.c-dist	2006-01-31 16:19:48.000000000 +0100
+++ src/fccfg.c	2006-01-31 16:42:41.000000000 +0100
@@ -383,10 +383,46 @@ FcConfigGetConfigDirs (FcConfig   *confi
     return FcStrListCreate (config->configDirs);
 }
 
+static FcChar8 *
+FcConfigLookupAllDirs (FcConfig *config, const FcChar8 *d)
+{
+    int n;
+    ino_t	di;
+    dev_t	dd;
+    struct stat s;
+
+    /* first we do string matches rather than file accesses */
+    for (n = 0; n < config->fontDirs->num; n++)
+    {
+	if (config->fontDirs->strs[n] == d ||
+	    strcmp ((char *)config->fontDirs->strs[n], (char *)d) == 0)
+	    return config->fontDirs->strs[n];
+    }
+
+    /* If this is a bottleneck, we can cache the fontDir inodes. */
+    if (stat ((char *)d, &s) == -1)
+	return 0;
+    di = s.st_ino; dd = s.st_dev;
+
+    for (n = 0; n < config->fontDirs->num; n++)
+    {
+	if (stat ((char *)config->fontDirs->strs[n], &s) == -1)
+	    continue;
+	if (di == s.st_ino && dd == s.st_dev)
+	    return config->fontDirs->strs[n];
+    }
+    return NULL;
+}
+
 FcBool
 FcConfigAddFontDir (FcConfig	    *config,
 		    const FcChar8   *d)
 {
+#if 1 /* to be sure */
+    /* already exists? */
+    if (FcConfigLookupAllDirs(config, d))
+	return FcTrue;
+#endif
     return FcStrSetAddFilename (config->fontDirs, d);
 }
 
@@ -397,6 +433,7 @@ FcConfigAddFontDirSubdirs (FcConfig     
     DIR *dir;
     struct dirent *e;
     FcChar8 *subdir;
+    FcBool added = FcFalse;
     
     if (!(dir = opendir ((char *) d)))
 	return FcFalse;
@@ -415,53 +452,42 @@ FcConfigAddFontDirSubdirs (FcConfig     
 	    strcat ((char *)subdir, e->d_name);
 	    if (FcFileIsDir (subdir))
 	    {
-		FcConfigAddFontDir (config, subdir);
+		if (FcConfigLookupAllDirs(config, subdir))
+		    continue; /* already added */
+		FcStrSetAddFilename (config->fontDirs, subdir);
 		FcConfigAddFontDirSubdirs (config, subdir);
+		added = FcTrue;
 	    }
 	}
     }
     free (subdir);
     closedir (dir);
-    return FcTrue;
+    return added;
 }
 
 const FcChar8 *
 FcConfigNormalizeFontDir (FcConfig  	*config, 
 			  const FcChar8 *d)
 {
-    /* If this is a bottleneck, we can cache the fontDir inodes. */
-    ino_t	di;
-    dev_t	dd;
+    FcChar8 *res;
     int		n, n0;
-    struct stat s;
+    FcBool added = FcFalse;
 
-    if (stat ((char *)d, &s) == -1)
-	return 0;
-    di = s.st_ino; dd = s.st_dev;
-
-    for (n = 0; n < config->fontDirs->num; n++)
-    {
-	if (stat ((char *)config->fontDirs->strs[n], &s) == -1)
-	    continue;
-	if (di == s.st_ino && dd == s.st_dev)
-	    return config->fontDirs->strs[n];
-    }
+    res = FcConfigLookupAllDirs(config, d);
+    if (res)
+	return res;
 
     /* Ok, we didn't find it in fontDirs; let's add subdirs.... */
-    for (n = 0, n0 = config->fontDirs->num; n < n0; n++)
-	FcConfigAddFontDirSubdirs (config, config->fontDirs->strs[n]);
+    for (n = 0, n0 = config->fontDirs->num; n < n0; n++) {
+	if (FcConfigAddFontDirSubdirs (config, config->fontDirs->strs[n]))
+	    added = FcTrue;
+    }
 
     /* ... and try again. */
-    for (n = 0; n < config->fontDirs->num; n++)
-    {
-	if (stat ((char *)config->fontDirs->strs[n], &s) == -1)
-	    continue;
-	if (di == s.st_ino && dd == s.st_dev)
-	    return config->fontDirs->strs[n];
-    }
+    if (added)
+	return FcConfigLookupAllDirs(config, d);
 
-    /* if it fails, then really give up. */
-    return 0;
+    return NULL;
 }
 
 FcBool

fontconfig-memleak-fix.patch:
 fccfg.c |    2 ++
 1 files changed, 2 insertions(+)

--- NEW FILE fontconfig-memleak-fix.patch ---
--- src/fccfg.c-dist	2006-01-31 19:41:12.000000000 +0100
+++ src/fccfg.c	2006-01-31 19:41:37.000000000 +0100
@@ -1849,6 +1849,7 @@ FcConfigAppFontAddFile (FcConfig    *con
 	}
 	FcStrListDone (sublist);
     }
+    FcStrSetDestroy (subdirs);
     return FcTrue;
 }
 
@@ -1896,6 +1897,7 @@ FcConfigAppFontAddDir (FcConfig	    *con
 	}
 	FcStrListDone (sublist);
     }
+    FcStrSetDestroy (subdirs);
     return FcTrue;
 }
 

fontconfig-misc-warning-fixes.patch:
 fc-cat/fc-cat.c |    5 ++---
 src/fccache.c   |   55 +++++++++++++++++++++++++++++++++++++++++++++----------
 src/fcxml.c     |    4 ++--
 3 files changed, 49 insertions(+), 15 deletions(-)

--- NEW FILE fontconfig-misc-warning-fixes.patch ---
diff -ru fontconfig-2.3.93.20060131.orig/fc-cat/fc-cat.c fontconfig-2.3.93.20060131/fc-cat/fc-cat.c
--- fontconfig-2.3.93.20060131.orig/fc-cat/fc-cat.c	2006-01-30 17:54:22.000000000 +0100
+++ fontconfig-2.3.93.20060131/fc-cat/fc-cat.c	2006-01-31 19:23:11.000000000 +0100
@@ -196,7 +196,7 @@
 
     while (1) 
     {
-	char * dir, * ls;
+	char * dir;
 	FcCacheReadString (fd, name_buf, sizeof (name_buf));
 	if (!strlen(name_buf))
 	    break;
@@ -241,7 +241,6 @@
 {
     int fd;
     char * current_arch_machine_name;
-    char candidate_arch_machine_name[9+MACHINE_SIGNATURE_SIZE];
     off_t current_arch_start = 0;
     char subdirName[FC_MAX_FILE_LEN + 1 + 12 + 1];
     static char name_buf[8192], *dir;
@@ -411,7 +410,7 @@
     if (i >= argc)
         usage (argv[0]);
 
-    if (name_buf = FcCacheFileRead (fs, dirs, argv[i]))
+    if ((name_buf = FcCacheFileRead (fs, dirs, argv[i])) != 0)
 	FcCachePrintSet (fs, dirs, name_buf);
     else
     {
fontconfig-2.3.93.20060131/fc-catだけに発見: fc-cat.c.orig
diff -ru fontconfig-2.3.93.20060131.orig/src/fccache.c fontconfig-2.3.93.20060131/src/fccache.c
--- fontconfig-2.3.93.20060131.orig/src/fccache.c	2006-01-31 11:25:37.000000000 +0100
+++ fontconfig-2.3.93.20060131/src/fccache.c	2006-01-31 19:31:07.000000000 +0100
@@ -251,10 +251,18 @@
 	    (config_time.set && cache_stat.st_mtime < config_time.time))
         {
             FcCache md;
+	    off_t off;
 
             FcStrSetAdd (staleDirs, FcStrCopy ((FcChar8 *)name_buf));
-            read (cache->fd, &md, sizeof (FcCache));
-            lseek (cache->fd, FcCacheNextOffset (lseek(cache->fd, 0, SEEK_CUR)) + md.count, SEEK_SET);
+            if (read (cache->fd, &md, sizeof (FcCache)) != sizeof(FcCache)) {
+		perror ("read metadata");
+		goto bail1;
+	    }
+	    off = FcCacheNextOffset (lseek(cache->fd, 0, SEEK_CUR)) + md.count;
+            if (lseek (cache->fd, off, SEEK_SET) != off) {
+		perror ("lseek");
+		goto bail1;
+	    }
             continue;
         }
 
@@ -468,16 +476,33 @@
         if (dir->name)
         {
 	    const char * d = (const char *)FcConfigNormalizeFontDir (config, (const FcChar8 *)dir->name);
-
+	    off_t off;
+	    
             FcCacheWriteString (fd, d);
 
 	    for (i = 0; i < dir->subdirs->size; i++)
 		FcCacheWriteString (fd, (char *)dir->subdirs->strs[i]);
 	    FcCacheWriteString (fd, "");
 	    
-            write (fd, &dir->metadata, sizeof(FcCache));
-            lseek (fd, FcCacheNextOffset (lseek(fd, 0, SEEK_CUR)), SEEK_SET);
-            write (fd, dir->ent, dir->metadata.count);
+            if (write (fd, &dir->metadata, sizeof(FcCache)) != sizeof(FcCache))
+	    {
+	        perror ("write metadata");
+		free (dir->ent);
+		continue;
+	    }
+	    off = FcCacheNextOffset (lseek(fd, 0, SEEK_CUR));
+            if (lseek (fd, off, SEEK_SET) != off)
+	    {
+		perror ("lseek");
+		free (dir->ent);
+		continue;
+	    }
+            if (write (fd, dir->ent, dir->metadata.count) != dir->metadata.count)
+	    {
+                perror ("write dirent");
+		free (dir->ent);
+		continue;
+	    }
             free (dir->ent);
         }
     }
@@ -1025,7 +1050,8 @@
     void * current_dir_block;
     off_t pos;
 
-    read(fd, &metadata, sizeof(FcCache));
+    if (read(fd, &metadata, sizeof(FcCache)) != sizeof(FcCache))
+	return FcFalse;
     if (metadata.magic != FC_CACHE_MAGIC)
         return FcFalse;
 
@@ -1238,11 +1264,20 @@
         FcCacheWriteString (fd, (char *)dirs->strs[i]);
     FcCacheWriteString (fd, "");
 
-    write (fd, &metadata, sizeof(FcCache));
+    if (write (fd, &metadata, sizeof(FcCache)) != sizeof(FcCache)) {
+	perror("write metadata");
+	goto bail5;
+    }
     if (metadata.count)
     {
-	lseek (fd, FcCacheNextOffset (lseek(fd, 0, SEEK_END)), SEEK_SET);
-	write (fd, current_dir_block, metadata.count);
+	off_t off = FcCacheNextOffset (lseek(fd, 0, SEEK_END)); 
+	if (lseek (fd, off, SEEK_SET) != off)
+	    perror("lseek");
+	else {
+	    if (write (fd, current_dir_block, metadata.count) != 
+		metadata.count)
+		perror("write current_dir_block");
+	}
 	free (current_dir_block);
     }
 
fontconfig-2.3.93.20060131/srcだけに発見: fccache.c.orig
diff -ru fontconfig-2.3.93.20060131.orig/src/fcxml.c fontconfig-2.3.93.20060131/src/fcxml.c
--- fontconfig-2.3.93.20060131.orig/src/fcxml.c	2006-01-26 17:14:29.000000000 +0100
+++ fontconfig-2.3.93.20060131/src/fcxml.c	2006-01-31 19:23:11.000000000 +0100
@@ -493,10 +493,10 @@
     {
 	if (parse->name)
 	    fprintf (stderr, "Fontconfig %s: \"%s\", line %d: ", s,
-		     parse->name, XML_GetCurrentLineNumber (parse->parser));
+		     parse->name, (int)XML_GetCurrentLineNumber (parse->parser));
 	else
 	    fprintf (stderr, "Fontconfig %s: line %d: ", s,
-		     XML_GetCurrentLineNumber (parse->parser));
+		     (int)XML_GetCurrentLineNumber (parse->parser));
 	if (severe >= FcSevereError)
 	    parse->error = FcTrue;
     }

fontconfig-seife-crash.patch:
 fcfs.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

--- NEW FILE fontconfig-seife-crash.patch ---
Index: src/fcfs.c
===================================================================
RCS file: /cvs/fontconfig/fontconfig/src/fcfs.c,v
retrieving revision 1.4.4.8
diff -u -3 -d -p -r1.4.4.8 fcfs.c
--- src/fcfs.c	25 Nov 2005 15:50:33 -0000	1.4.4.8
+++ src/fcfs.c	1 Feb 2006 19:04:23 -0000
@@ -159,23 +159,23 @@ FcFontSetUnserialize(FcCache * metadata,
     nfont = *(int *)block_ptr;
     block_ptr = (int *)block_ptr + 1;
 
-    if (s->sfont < s->nfont + nfont)
-    {
-	int sfont = s->nfont + nfont;
-	FcPattern ** pp;
-	pp = realloc (s->fonts, sfont * sizeof (FcPattern));
-	if (!pp)
-	    return FcFalse;
-	s->fonts = pp;
-	s->sfont = sfont;
-    }
-    n = s->nfont;
-    s->nfont += nfont;
-
-    if (nfont > 0)
+    if (nfont > 0 && s->nfont < s->nfont + nfont)
     {
 	FcPattern * p = (FcPattern *)block_ptr;
 
+	if (s->sfont < s->nfont + nfont)
+	{
+	    int sfont = s->nfont + nfont;
+	    FcPattern ** pp;
+	    pp = realloc (s->fonts, sfont * sizeof (FcPattern));
+	    if (!pp)
+		return FcFalse;
+	    s->fonts = pp;
+	    s->sfont = sfont;
+	}
+	n = s->nfont;
+	s->nfont += nfont;
+
         /* The following line is a bit counterintuitive.  The usual
          * convention is that FcPatternUnserialize is responsible for
          * aligning the FcPattern.  However, the FontSet also stores
@@ -187,7 +187,7 @@ FcFontSetUnserialize(FcCache * metadata,
 
 	block_ptr = FcPatternUnserialize (metadata, block_ptr);
 	block_ptr = FcObjectUnserialize (metadata, block_ptr);
+        return block_ptr != 0;
     }
-
-    return block_ptr != 0;
+    return FcFalse;
 }


Index: fontconfig.spec
===================================================================
RCS file: /cvs/dist/rpms/fontconfig/devel/fontconfig.spec,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- fontconfig.spec	31 Jan 2006 13:44:03 -0000	1.61
+++ fontconfig.spec	2 Feb 2006 15:07:23 -0000	1.62
@@ -3,7 +3,7 @@
 Summary: Font configuration and customization library
 Name: fontconfig
 Version: 2.3.93.cvs20060131
-Release: 1
+Release: 2
 License: MIT
 Group: System Environment/Libraries
 Source: http://fontconfig.org/release/fontconfig-%{version}.tar.gz
@@ -13,6 +13,11 @@
 Source2: 50-no-hint-fonts.conf
 
 Patch1: fontconfig-2.3.93-defaultconfig.patch
+Patch2: fontconfig-fontsubdir-parse-fix.patch
+Patch3: fontconfig-memleak-fix.patch
+Patch4: fontconfig-misc-warning-fixes.patch
+Patch5: fontconfig-fccache-update-check.patch
+Patch6: fontconfig-seife-crash.patch
 
 BuildRequires: freetype-devel >= %{freetype_version}
 BuildRequires: expat-devel
@@ -49,6 +54,11 @@
 %setup -q
 
 %patch1 -p1 -b .defaultconfig
+%patch2 -p0 -b .fontsubdir-parse-fix
+%patch3 -p0 -b .fontconfig-memleak-fix
+%patch4 -p1 -b .fontconfig-misc-warning-fixes
+%patch5 -p0 -b .fontconfig-fccache-update-check
+%patch6 -p0 -b .fontconfig-seife-crash
 
 %build
 %configure --with-add-fonts=/usr/share/X11/fonts/Type1,/usr/share/X11/fonts/OTF
@@ -133,6 +143,9 @@
 %{_mandir}/man3/*
 
 %changelog
+* Thu Feb  2 2006 Matthias Clasen <mclasen at redhat.com> - 2.3.93.cvs20060131-2
+- Accumulated patches
+
 * Tue Jan 31 2006 Matthias Clasen <mclasen at redhat.com> - 2.3.93.cvs20060131-1
 - Newer cvs snapshot
 




More information about the fedora-cvs-commits mailing list