summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Brodin <antoine@FreeBSD.org>2018-01-13 09:53:15 +0000
committerAntoine Brodin <antoine@FreeBSD.org>2018-01-13 09:53:15 +0000
commit75daa7974d1ebc8d34281d37ce0f6b44e6e34917 (patch)
treebae83fd77ae40b7e69f667c32208c5d0f83f6096
parentFix PKGBASE collision with cad/kicad-library (diff)
Work around sem_unlink bug on FreeBSD when /tmp is using tmpfs
PR: 189353
Notes
Notes: svn path=/head/; revision=458923
-rw-r--r--security/yara/Makefile1
-rw-r--r--security/yara/files/patch-threading.c37
2 files changed, 38 insertions, 0 deletions
diff --git a/security/yara/Makefile b/security/yara/Makefile
index 56f6c574283c..b1d21e60771f 100644
--- a/security/yara/Makefile
+++ b/security/yara/Makefile
@@ -2,6 +2,7 @@
PORTNAME= yara
PORTVERSION= 3.7.0
+PORTREVISION= 1
DISTVERSIONPREFIX= v
CATEGORIES= security
diff --git a/security/yara/files/patch-threading.c b/security/yara/files/patch-threading.c
new file mode 100644
index 000000000000..65a26bbbf3a1
--- /dev/null
+++ b/security/yara/files/patch-threading.c
@@ -0,0 +1,37 @@
+# Work around FreeBSD bug #189353 when /tmp is using tmpfs(5)
+
+--- threading.c.orig 2017-11-10 11:21:21 UTC
++++ threading.c
+@@ -33,6 +33,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
+ #include <errno.h>
+ #endif
+
++#if defined(__FreeBSD__)
++#include <stdlib.h>
++#endif
++
+ #include "threading.h"
+
+
+@@ -88,6 +92,11 @@ int semaphore_init(
+ *semaphore = CreateSemaphore(NULL, value, 65535, NULL);
+ if (*semaphore == NULL)
+ return GetLastError();
++ #elif defined(__FreeBSD__)
++ *semaphore = malloc(sizeof(sem_t));
++ if (*semaphore == NULL)
++ return errno;
++ return sem_init(*semaphore, 0, value);
+ #else
+ // Mac OS X doesn't support unnamed semaphores via sem_init, that's why
+ // we use sem_open instead sem_init and immediately unlink the semaphore
+@@ -112,6 +121,9 @@ void semaphore_destroy(
+ {
+ #if defined(_WIN32) || defined(__CYGWIN__)
+ CloseHandle(*semaphore);
++ #elif defined(__FreeBSD__)
++ sem_close(*semaphore);
++ free(*semaphore);
+ #else
+ sem_close(*semaphore);
+ #endif