ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/mail/sendmail/patches/102-pthreads-stack-size.patch b/external/subpack/mail/sendmail/patches/102-pthreads-stack-size.patch
new file mode 100644
index 0000000..aec19bf
--- /dev/null
+++ b/external/subpack/mail/sendmail/patches/102-pthreads-stack-size.patch
@@ -0,0 +1,44 @@
+This patch increases the stack size for pthreads from 80 KB, the default
+stack size for musl libc, to 2 MB. The default stack size for glibc is 8 MB.
+
+OpenDKIM, an application that depends on libmilter, segfaults if the stack
+size for pthreads is left unchanged at the musl default value of 80 KB.
+Apparently, OpenDKIM allocates blocks of 64 KB multiple times, which causes
+libmilter and therefore OpenDKIM to crash:
+https://git.alpinelinux.org/cgit/aports/commit/?id=95724d1bd53ae87f72e6388cb7323dbd8f84be9d
+
+This patch follows the patch suggested by an Alpine Linux user in bug report
+above. Also, a bug report has been filed upstream:
+https://sourceforge.net/p/opendkim/bugs/258/
+
+
+--- a/libmilter/libmilter.h
++++ b/libmilter/libmilter.h
+@@ -127,10 +127,10 @@ struct smfi_str
+ # define MI_SOCK_READ(s, b, l) read(s, b, l)
+ # define MI_SOCK_READ_FAIL(x) ((x) < 0)
+ # define MI_SOCK_WRITE(s, b, l) write(s, b, l)
+-
+-# define thread_create(ptid,wr,arg) pthread_create(ptid, NULL, wr, arg)
+ # define sthread_get_id() pthread_self()
+
++extern int thread_create(pthread_t *ptid, void *(*wr) (void *), void *arg);
++
+ typedef pthread_mutex_t smutex_t;
+ # define smutex_init(mp) (pthread_mutex_init(mp, NULL) == 0)
+ # define smutex_destroy(mp) (pthread_mutex_destroy(mp) == 0)
+--- a/libmilter/main.c
++++ b/libmilter/main.c
+@@ -16,6 +16,12 @@ SM_RCSID("@(#)$Id: main.c,v 8.85 2013-11
+ #include <fcntl.h>
+ #include <sys/stat.h>
+
++int thread_create(pthread_t *ptid, void *(*wr) (void *), void *arg) {
++ pthread_attr_t attr;
++ pthread_attr_init(&attr);
++ pthread_attr_setstacksize(&attr,2*1024*1024);
++ return pthread_create(ptid, &attr, wr, arg);
++}
+
+ static smfiDesc_ptr smfi = NULL;
+