uwrap: Fix a possible null pointer dereference
authorAndreas Schneider <asn@samba.org>
Fri, 30 Oct 2015 12:37:11 +0000 (13:37 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 5 Nov 2015 08:23:15 +0000 (09:23 +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>
lib/uid_wrapper/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