fontconfig: Branch 'master' - 2 commits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 configure.ac    |   20 ++++++++++++++++++++
 src/fcdefault.c |   34 +++++++++++++++++++++++++++-------
 src/fcint.h     |    6 ++++++
 src/fcobjs.c    |    4 ++--
 src/fcstat.c    |   12 +++++++++++-
 5 files changed, 66 insertions(+), 10 deletions(-)

New commits:
commit abdb6d658e1a16410dd1c964e365a3ebd5039e7c
Author: Akira TAGOH <akira@xxxxxxxxx>
Date:   Wed Mar 1 19:48:02 2017 +0900

    Fix the build issue on GNU/Hurd
    
    PATH_MAX isn't defined on GNU/Hurd. according to the porting guidelines
    (https://www.gnu.org/software/hurd/hurd/porting/guidelines.html)
    allocate a memory dynamically instead of relying on the length of
    a string with PATH_MAX.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=97512

diff --git a/src/fcdefault.c b/src/fcdefault.c
index 6647a8f..5afd7ec 100644
--- a/src/fcdefault.c
+++ b/src/fcdefault.c
@@ -148,17 +148,34 @@ retry:
 	    prgname = FcStrdup ("");
 #else
 # if defined (HAVE_GETEXECNAME)
-	const char *p = getexecname ();
+	char *p = FcStrdup(getexecname ());
 # elif defined (HAVE_READLINK)
-	char buf[PATH_MAX + 1];
-	int len;
+	size_t size = FC_PATH_MAX;
 	char *p = NULL;
 
-	len = readlink ("/proc/self/exe", buf, sizeof (buf) - 1);
-	if (len != -1)
+	while (1)
 	{
-	    buf[len] = '\0';
-	    p = buf;
+	    char *buf = malloc (size);
+	    ssize_t len;
+
+	    if (!buf)
+		break;
+
+	    len = readlink ("/proc/self/exe", buf, size - 1);
+	    if (len < 0)
+	    {
+		free (buf);
+		break;
+	    }
+	    if (len < size - 1)
+	    {
+		buf[len] = 0;
+		p = buf;
+		break;
+	    }
+
+	    free (buf);
+	    size *= 2;
 	}
 # else
 	char *p = NULL;
@@ -176,6 +193,9 @@ retry:
 
 	if (!prgname)
 	    prgname = FcStrdup ("");
+
+	if (p)
+	    free (p);
 #endif
 
 	if (!fc_atomic_ptr_cmpexch (&default_prgname, NULL, prgname)) {
diff --git a/src/fcint.h b/src/fcint.h
index ac911ad..dad34c5 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -70,6 +70,12 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
 #  define FC_DIR_SEPARATOR_S       "/"
 #endif
 
+#ifdef PATH_MAX
+#define FC_PATH_MAX	PATH_MAX
+#else
+#define FC_PATH_MAX	128
+#endif
+
 #if __GNUC__ >= 4
 #define FC_UNUSED	__attribute__((unused))
 #else
diff --git a/src/fcstat.c b/src/fcstat.c
index 1734fa4..f6e1aaa 100644
--- a/src/fcstat.c
+++ b/src/fcstat.c
@@ -278,8 +278,13 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
 	{
 #endif
 	struct stat statb;
-	char f[PATH_MAX + 1];
+	char *f = malloc (len + 1 + dlen + 1);
 
+	if (!f)
+	{
+	    ret = -1;
+	    goto bail;
+	}
 	memcpy (f, dir, len);
 	f[len] = FC_DIR_SEPARATOR;
 	memcpy (&f[len + 1], files[n]->d_name, dlen);
@@ -287,11 +292,16 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
 	if (lstat (f, &statb) < 0)
 	{
 	    ret = -1;
+	    free (f);
 	    goto bail;
 	}
 	if (S_ISDIR (statb.st_mode))
+	{
+	    free (f);
 	    goto bail;
+	}
 
+	free (f);
 	dtype = statb.st_mode;
 #ifdef HAVE_STRUCT_DIRENT_D_TYPE
 	}
commit 9878b306f6c673d3d6cd9db487f67eb426cc03df
Author: Akira TAGOH <akira@xxxxxxxxx>
Date:   Thu Feb 23 21:39:10 2017 +0900

    Fix the build issue with gperf 3.1
    
    To support the one of changes in gperf 3.1:
    * The 'len' parameter of the hash function and of the lookup function is now
      of type 'size_t' instead of 'unsigned int'. This makes it safe to call these
      functions with strings of length > 4 GB, on 64-bit machines.

diff --git a/configure.ac b/configure.ac
index 4948816..8fbf3d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -193,6 +193,26 @@ fi
 AC_CHECK_MEMBERS([struct dirent.d_type],,,
 	[#include <dirent.h>])
 
+# Check the argument type of the gperf hash/lookup function
+AC_MSG_CHECKING([The type of len parameter of gperf hash/lookup function])
+fc_gperf_test="$(echo 'foo' | gperf -L ANSI-C)"
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+	#include <string.h>
+
+	const char *in_word_set(register const char *, register size_t);
+	$fc_gperf_test
+	]])], [FC_GPERF_SIZE_T=size_t],
+	[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+		#include <string.h>
+
+		const char *in_word_set(register const char *, register unsigned int);
+		$fc_gperf_test
+	]])], [FC_GPERF_SIZE_T="unsigned int"],
+	[AC_MSG_ERROR([Unable to determine the type of the len parameter of the gperf hash/lookup function])]
+)])
+AC_DEFINE_UNQUOTED(FC_GPERF_SIZE_T, $FC_GPERF_SIZE_T, [The type of len parameter of the gperf hash/lookup function])
+AC_MSG_RESULT($FC_GPERF_SIZE_T)
+
 #
 # Checks for iconv
 #
diff --git a/src/fcobjs.c b/src/fcobjs.c
index 16ff31c..33bba8d 100644
--- a/src/fcobjs.c
+++ b/src/fcobjs.c
@@ -25,10 +25,10 @@
 #include "fcint.h"
 
 static unsigned int
-FcObjectTypeHash (register const char *str, register unsigned int len);
+FcObjectTypeHash (register const char *str, register FC_GPERF_SIZE_T len);
 
 static const struct FcObjectTypeInfo *
-FcObjectTypeLookup (register const char *str, register unsigned int len);
+FcObjectTypeLookup (register const char *str, register FC_GPERF_SIZE_T len);
 
 #include "fcobjshash.h"
 
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/fontconfig




[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux