summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/nss_compat.c
diff options
context:
space:
mode:
authornectar <nectar@FreeBSD.org>2004-03-30 15:56:15 +0000
committernectar <nectar@FreeBSD.org>2004-03-30 15:56:15 +0000
commit7ec3e333012ba329299be5ca10738792b75cac89 (patch)
tree6dc88cfd8956062abed823d14f63a72bf26ad661 /lib/libc/net/nss_compat.c
parentb3ec818746c286dc776ca38f929c2a1feed43c79 (diff)
downloadFreeBSD-src-7ec3e333012ba329299be5ca10738792b75cac89.zip
FreeBSD-src-7ec3e333012ba329299be5ca10738792b75cac89.tar.gz
When a dynamic NSS module is built and linked against a thread
library, it may pull in that thread library at run time. If the process started out single-threaded, this could cause attempts to release locks that do not exist. Guard against this possibility by checking __isthreaded before invoking thread primitives. A similar problem remains if the process is linked against one thread library, but the NSS module is linked against another. This can only be avoided by careful design of the NSS module. Submitted by: Sean McNeil <sean@mcneil.com> (mostly; bugs are mine)
Diffstat (limited to 'lib/libc/net/nss_compat.c')
-rw-r--r--lib/libc/net/nss_compat.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/net/nss_compat.c b/lib/libc/net/nss_compat.c
index a81ec8a..09a2d4f 100644
--- a/lib/libc/net/nss_compat.c
+++ b/lib/libc/net/nss_compat.c
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <pthread.h>
#include <pthread_np.h>
#include "un-namespace.h"
+#include "libc_private.h"
struct group;
@@ -60,7 +61,7 @@ static pthread_once_t _term_once_##x = PTHREAD_ONCE_INIT
#define SET_TERMINATOR(x, y) \
do { \
- if (_pthread_main_np()) \
+ if (!__isthreaded || _pthread_main_np()) \
_term_main_##x = (y); \
else { \
(void)_pthread_once(&_term_once_##x, _term_create_##x); \
@@ -69,7 +70,7 @@ do { \
} while (0)
#define CHECK_TERMINATOR(x) \
-(_pthread_main_np() ? \
+(!__isthreaded || _pthread_main_np() ? \
(_term_main_##x) : \
((void)_pthread_once(&_term_once_##x, _term_create_##x), \
_pthread_getspecific(_term_key_##x)))
OpenPOWER on IntegriCloud