aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-03-15 20:54:16 +0000
committerChristian Grothoff <christian@grothoff.org>2016-03-15 20:54:16 +0000
commitc39414cdc7a461ee573205cfe371853d0d1f94d8 (patch)
tree6c03ee06107039a589c6b702421e372f95cf4ffc
parentc932ba77fde49a5c22374de96b8e56b17e746462 (diff)
downloadlibmicrohttpd-c39414cdc7a461ee573205cfe371853d0d1f94d8.tar.gz
libmicrohttpd-c39414cdc7a461ee573205cfe371853d0d1f94d8.zip
Dan Dedrick wrote:
If pthread_create fails for some reason we need to not access the thread pointer as it will not be valid. Without this check a failed return code from pthread_create would cause a SIGSEGV to occur. An instance that pthread_create could fail is if enough connections were established that we ran out of space in our mapping to create another thread stack. Specifically I have seen this occur with systemd-journal-gatewayd where there was a bug with not releasing connections after they had disconnected. I submitted a fix for that here: https://github.com/systemd/systemd/pull/2287 but it would really be best if libmicrohttpd didn't SIGSEGV under these conditions.
-rw-r--r--ChangeLog3
-rw-r--r--src/include/microhttpd.h2
-rw-r--r--src/microhttpd/daemon.c3
3 files changed, 6 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 402463eb..5b3ef9e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
1Tue Mar 15 21:52:27 CET 2016
2 Do not crash if pthread_create() fails. -DD
3
1Tue Mar 15 20:29:34 CET 2016 4Tue Mar 15 20:29:34 CET 2016
2 Do not use eready DLL data structure unless 5 Do not use eready DLL data structure unless
3 we are actually using epoll(). -DD/CG 6 we are actually using epoll(). -DD/CG
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 61eebb80..43309548 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -130,7 +130,7 @@ typedef intptr_t ssize_t;
130 * Current version of the library. 130 * Current version of the library.
131 * 0x01093001 = 1.9.30-1. 131 * 0x01093001 = 1.9.30-1.
132 */ 132 */
133#define MHD_VERSION 0x00094803 133#define MHD_VERSION 0x00094804
134 134
135/** 135/**
136 * MHD-internal return code for "YES". 136 * MHD-internal return code for "YES".
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 14786042..e4d4e913 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1283,7 +1283,8 @@ create_thread (MHD_thread_handle_ *thread,
1283 ret = pthread_create (thread, pattr, 1283 ret = pthread_create (thread, pattr,
1284 start_routine, arg); 1284 start_routine, arg);
1285#ifdef HAVE_PTHREAD_SETNAME_NP 1285#ifdef HAVE_PTHREAD_SETNAME_NP
1286 (void) pthread_setname_np (*thread, "libmicrohttpd"); 1286 if (0 == ret)
1287 (void) pthread_setname_np (*thread, "libmicrohttpd");
1287#endif /* HAVE_PTHREAD_SETNAME_NP */ 1288#endif /* HAVE_PTHREAD_SETNAME_NP */
1288 if (0 != daemon->thread_stack_size) 1289 if (0 != daemon->thread_stack_size)
1289 pthread_attr_destroy (&attr); 1290 pthread_attr_destroy (&attr);