uwrap: Fix a possible null pointer dereference
authorAndreas Schneider <asn@samba.org>
Tue, 20 Oct 2015 13:06:02 +0000 (15:06 +0200)
committerAndreas Schneider <asn@samba.org>
Tue, 27 Oct 2015 13:54:21 +0000 (14:54 +0100)
If uid_wrapper is loaded but not enabled (UID_WRAPPER environment
variable not set), then we dereference a NULL pointer while forking.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
src/uid_wrapper.c

index 3f9ce98f4392dce4166646166203ad38ff113bb5..60477d2b78edafa1df581c82b1dbc5e46c61d04b 100644 (file)
@@ -812,6 +812,11 @@ static void uwrap_thread_prepare(void)
 {
        struct uwrap_thread *id = uwrap_tls_id;
 
+       /* uid_wrapper is loaded but not enabled */
+       if (id == NULL) {
+               return;
+       }
+
        UWRAP_LOCK_ALL;
 
        /*
@@ -826,6 +831,12 @@ static void uwrap_thread_prepare(void)
 static void uwrap_thread_parent(void)
 {
        struct uwrap_thread *id = uwrap_tls_id;
+
+       /* uid_wrapper is loaded but not enabled */
+       if (id == NULL) {
+               return;
+       }
+
        id->enabled = true;
 
        UWRAP_UNLOCK_ALL;
@@ -836,6 +847,11 @@ static void uwrap_thread_child(void)
        struct uwrap_thread *id = uwrap_tls_id;
        struct uwrap_thread *u = uwrap.ids;
 
+       /* uid_wrapper is loaded but not enabled */
+       if (id == NULL) {
+               return;
+       }
+
        /*
         * "Garbage collector" - Inspired by DESTRUCTOR.
         * All threads (except one which called fork()) are dead now.. Dave