server: Fix assignment of primary_group in token_duplicate.

Sebastian Lackner sebastian at fds-team.de
Thu Dec 10 10:40:06 CST 2015


Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---

We should reference the newly allocated group, not the group of the
parent token. I'm not aware of any way to trigger this issue (without
further patches), but it looks easy enough to fix it anyway.

 server/token.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/server/token.c b/server/token.c
index 42cfb3d..6c2871f 100644
--- a/server/token.c
+++ b/server/token.c
@@ -559,6 +559,7 @@ struct token *token_duplicate( struct token *src_token, unsigned primary,
     if (!token) return token;
 
     /* copy groups */
+    token->primary_group = NULL;
     LIST_FOR_EACH_ENTRY( group, &src_token->groups, struct group, entry )
     {
         size_t size = FIELD_OFFSET( struct group, sid.SubAuthority[group->sid.SubAuthorityCount] );
@@ -570,8 +571,9 @@ struct token *token_duplicate( struct token *src_token, unsigned primary,
         }
         memcpy( newgroup, group, size );
         list_add_tail( &token->groups, &newgroup->entry );
+        if (src_token->primary_group == &group->sid)
+            token->primary_group = &newgroup->sid;
     }
-    token->primary_group = src_token->primary_group;
     assert( token->primary_group );
 
     /* copy privileges */
-- 
2.6.2



More information about the wine-patches mailing list