aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-01-08 12:40:16 +0100
committermarha <marha@users.sourceforge.net>2013-01-08 12:40:16 +0100
commitc2ada0e240f7c721ed09c9570b5375833c47370c (patch)
treeedf46fc67b3b6af1a10b2e5e223712fdc6dc77ea /fontconfig/src
parent066de3c6d46ca099caba474b8e7d132ec772bc65 (diff)
parent8a26872f0c9102cb357345eca24a4bf7401bbe70 (diff)
downloadvcxsrv-c2ada0e240f7c721ed09c9570b5375833c47370c.tar.gz
vcxsrv-c2ada0e240f7c721ed09c9570b5375833c47370c.tar.bz2
vcxsrv-c2ada0e240f7c721ed09c9570b5375833c47370c.zip
Merge remote-tracking branch 'origin/released'
* origin/released: fontconfig mesa git update 8 jan 2013 Conflicts: fontconfig/src/fccache.c
Diffstat (limited to 'fontconfig/src')
-rw-r--r--fontconfig/src/Makefile.am1
-rwxr-xr-xfontconfig/src/fcatomic.c3
-rwxr-xr-x[-rw-r--r--]fontconfig/src/fccache.c6
-rw-r--r--fontconfig/src/fccompat.c107
-rw-r--r--fontconfig/src/fcint.h7
-rw-r--r--fontconfig/src/fcstat.c2
-rwxr-xr-xfontconfig/src/fcxml.c2
7 files changed, 121 insertions, 7 deletions
diff --git a/fontconfig/src/Makefile.am b/fontconfig/src/Makefile.am
index 617713fe7..dba42065a 100644
--- a/fontconfig/src/Makefile.am
+++ b/fontconfig/src/Makefile.am
@@ -131,6 +131,7 @@ libfontconfig_la_SOURCES = \
fccache.c \
fccfg.c \
fccharset.c \
+ fccompat.c \
fcdbg.c \
fcdefault.c \
fcdir.c \
diff --git a/fontconfig/src/fcatomic.c b/fontconfig/src/fcatomic.c
index 45048aa9f..c35a829fd 100755
--- a/fontconfig/src/fcatomic.c
+++ b/fontconfig/src/fcatomic.c
@@ -50,7 +50,6 @@
#include "fcint.h"
#include <sys/types.h>
#include <sys/stat.h>
-#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
@@ -109,7 +108,7 @@ FcAtomicLock (FcAtomic *atomic)
strcpy ((char *) atomic->tmp, (char *) atomic->file);
strcat ((char *) atomic->tmp, TMP_NAME);
- fd = mkstemp ((char *) atomic->tmp);
+ fd = FcMakeTempfile ((char *) atomic->tmp);
if (fd < 0)
return FcFalse;
f = fdopen (fd, "w");
diff --git a/fontconfig/src/fccache.c b/fontconfig/src/fccache.c
index 5926a398b..c37cbe148 100644..100755
--- a/fontconfig/src/fccache.c
+++ b/fontconfig/src/fccache.c
@@ -156,7 +156,7 @@ FcDirCacheOpenFile (const FcChar8 *cache_file, struct stat *file_stat)
if (FcStat (cache_file, file_stat) < 0)
return -1;
#endif
- fd = open((char *) cache_file, O_RDONLY | O_BINARY);
+ fd = FcOpen((char *) cache_file, O_RDONLY | O_BINARY);
if (fd < 0)
return fd;
#ifndef _WIN32
@@ -978,7 +978,7 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
if (!FcAtomicLock (atomic))
goto bail3;
- fd = open((char *)FcAtomicNewFile (atomic), O_RDWR | O_CREAT | O_BINARY, 0666);
+ fd = FcOpen((char *)FcAtomicNewFile (atomic), O_RDWR | O_CREAT | O_BINARY, 0666);
if (fd == -1)
goto bail4;
@@ -1456,7 +1456,7 @@ FcDirCacheCreateTagFile (const FcChar8 *cache_dir)
goto bail1;
if (!FcAtomicLock (atomic))
goto bail2;
- fd = open((char *)FcAtomicNewFile (atomic), O_RDWR | O_CREAT, 0644);
+ fd = FcOpen((char *)FcAtomicNewFile (atomic), O_RDWR | O_CREAT, 0644);
if (fd == -1)
goto bail3;
fp = fdopen(fd, "wb");
diff --git a/fontconfig/src/fccompat.c b/fontconfig/src/fccompat.c
new file mode 100644
index 000000000..169cab9ed
--- /dev/null
+++ b/fontconfig/src/fccompat.c
@@ -0,0 +1,107 @@
+/*
+ * fontconfig/src/fccompat.c
+ *
+ * Copyright © 2012 Red Hat, Inc.
+ *
+ * Author(s):
+ * Akira TAGOH
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the author(s) not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The authors make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "fcint.h"
+
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#include <stdarg.h>
+#include <stdlib.h>
+
+#ifdef O_CLOEXEC
+#define FC_O_CLOEXEC O_CLOEXEC
+#else
+#define FC_O_CLOEXEC 0
+#endif
+#ifdef O_LARGEFILE
+#define FC_O_LARGEFILE O_LARGEFILE
+#else
+#define FC_O_LARGEFILE 0
+#endif
+
+int
+FcOpen(const char *pathname, int flags, ...)
+{
+ int fd = -1;
+
+ if (flags & O_CREAT)
+ {
+ va_list ap;
+ mode_t mode;
+
+ va_start(ap, flags);
+ mode = (mode_t) va_arg(ap, int);
+ va_end(ap);
+
+ fd = open(pathname, flags | FC_O_CLOEXEC | FC_O_LARGEFILE, mode);
+ }
+ else
+ {
+ fd = open(pathname, flags | FC_O_CLOEXEC | FC_O_LARGEFILE);
+ }
+
+ return fd;
+}
+
+int
+FcMakeTempfile (char *template)
+{
+ int fd = -1;
+
+#if HAVE_MKOSTEMP
+ fd = mkostemp (template, FC_O_CLOEXEC);
+#elif HAVE_MKSTEMP
+ fd = mkstemp (template);
+# ifdef F_DUPFD_CLOEXEC
+ if (fd != -1)
+ {
+ int newfd = fcntl(fd, F_DUPFD_CLOEXEC);
+
+ close(fd);
+ fd = newfd;
+ }
+# elif defined(FD_CLOEXEC)
+ if (fd != -1)
+ {
+ fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
+ }
+# endif
+#elif HAVE__MKTEMP_S
+ if (_mktemp_s(template, strlen(template) + 1) != 0)
+ return -1;
+ fd = FcOpen(template, O_RDWR | O_EXCL | O_CREAT, 0600);
+#else
+#error no secure functions to create a temporary file
+#endif
+
+ return fd;
+}
diff --git a/fontconfig/src/fcint.h b/fontconfig/src/fcint.h
index 38bd9bb73..3883bc96e 100644
--- a/fontconfig/src/fcint.h
+++ b/fontconfig/src/fcint.h
@@ -717,6 +717,13 @@ FcCharSetSerialize(FcSerialize *serialize, const FcCharSet *cs);
FcPrivate FcChar16 *
FcCharSetGetNumbers(const FcCharSet *c);
+/* fccompat.c */
+FcPrivate int
+FcOpen(const char *pathname, int flags, ...);
+
+FcPrivate int
+FcMakeTempfile (char *template);
+
/* fcdbg.c */
FcPrivate void
diff --git a/fontconfig/src/fcstat.c b/fontconfig/src/fcstat.c
index 9763c21a4..390f45c37 100644
--- a/fontconfig/src/fcstat.c
+++ b/fontconfig/src/fcstat.c
@@ -336,7 +336,7 @@ FcIsFsMmapSafe (int fd)
FcBool
FcIsFsMtimeBroken (const FcChar8 *dir)
{
- int fd = open ((const char *) dir, O_RDONLY);
+ int fd = FcOpen ((const char *) dir, O_RDONLY);
if (fd != -1)
{
diff --git a/fontconfig/src/fcxml.c b/fontconfig/src/fcxml.c
index 5b074c88e..cd6aa3109 100755
--- a/fontconfig/src/fcxml.c
+++ b/fontconfig/src/fcxml.c
@@ -2980,7 +2980,7 @@ FcConfigParseAndLoad (FcConfig *config,
if (FcDebug () & FC_DBG_CONFIG)
printf ("\tLoading config file %s\n", filename);
- fd = open ((char *) filename, O_RDONLY);
+ fd = FcOpen ((char *) filename, O_RDONLY);
if (fd == -1) {
FcStrFree (filename);
goto bail0;