aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Beich <jbeich@FreeBSD.org>2017-07-06 03:02:59 +0000
committerJan Beich <jbeich@FreeBSD.org>2017-07-06 03:02:59 +0000
commit60d33320b62b3d64a3ef194207656913232de339 (patch)
tree9a658ae4ea8929415b0adf78f8e277355308e962
parent7d6471a18c6ddd810d0bfd7f661106c8bae6aba5 (diff)
downloadports-60d33320b62b3d64a3ef194207656913232de339.tar.gz
ports-60d33320b62b3d64a3ef194207656913232de339.zip
MFH: r445016
x11/libxshmfence: don't leak /tmp/shmfd* files with O_CLOEXEC - Both mkostemp() and mkstemp() need explicit call to unlink() - Unobfuscate fallback if both O_TMPFILE and mksotemp() are N/A - O_TMPFILE (Linux-only) appeared after O_CLOEXEC, no need to check PR: 217676 (for tracking) Approved by: ports-secteam (junovitch)
Notes
Notes: svn path=/branches/2017Q2/; revision=445125
-rw-r--r--x11/libxshmfence/Makefile2
-rw-r--r--x11/libxshmfence/files/patch-src__xshmfence_alloc.c28
2 files changed, 10 insertions, 20 deletions
diff --git a/x11/libxshmfence/Makefile b/x11/libxshmfence/Makefile
index bbe463f6d524..d325e00c7ad2 100644
--- a/x11/libxshmfence/Makefile
+++ b/x11/libxshmfence/Makefile
@@ -2,7 +2,7 @@
PORTNAME= libxshmfence
PORTVERSION= 1.2
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= x11
MAINTAINER= x11@FreeBSD.org
diff --git a/x11/libxshmfence/files/patch-src__xshmfence_alloc.c b/x11/libxshmfence/files/patch-src__xshmfence_alloc.c
index ea14877817ec..e6e0df9a946e 100644
--- a/x11/libxshmfence/files/patch-src__xshmfence_alloc.c
+++ b/x11/libxshmfence/files/patch-src__xshmfence_alloc.c
@@ -1,24 +1,14 @@
--- src/xshmfence_alloc.c.orig 2015-03-04 15:28:23 UTC
+++ src/xshmfence_alloc.c
-@@ -67,15 +67,19 @@ int
- xshmfence_alloc_shm(void)
- {
- char template[] = SHMDIR "/shmfd-XXXXXX";
-- int fd;
-+ int fd = -1;
-
- #if HAVE_MEMFD_CREATE
- fd = memfd_create("xshmfence", MFD_CLOEXEC|MFD_ALLOW_SEALING);
- if (fd < 0)
- #endif
- {
--#ifdef O_TMPFILE
-+#if defined(O_CLOEXEC)
-+#if defined(HAVE_MKOSTEMP)
-+ fd = mkostemp(template, O_CLOEXEC);
-+#elif defined(O_TMPFILE)
- fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
-+#endif
+@@ -79,7 +79,11 @@ xshmfence_alloc_shm(void)
if (fd < 0)
#endif
{
++#ifdef HAVE_MKOSTEMP
++ fd = mkostemp(template, O_CLOEXEC);
++#else
+ fd = mkstemp(template);
++#endif
+ if (fd < 0)
+ return fd;
+ unlink(template);