s3: Use talloc_memdup in copy_unix_token
authorVolker Lendecke <vl@samba.org>
Sat, 28 May 2011 08:38:52 +0000 (10:38 +0200)
committerVolker Lendecke <vl@samba.org>
Sat, 28 May 2011 08:39:48 +0000 (10:39 +0200)
source3/locking/locking.c

index f3a8d8c3f5c342372f24dd909d50f12c6c6bddc4..3e511c487d4fad143b1b12802f5dadc241760d43 100644 (file)
@@ -1493,11 +1493,11 @@ static struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct
        cpy->ngroups = tok->ngroups;
        if (tok->ngroups) {
                /* Make this a talloc child of cpy. */
-               cpy->groups = TALLOC_ARRAY(cpy, gid_t, tok->ngroups);
+               cpy->groups = (gid_t *)talloc_memdup(
+                       cpy, tok->groups, tok->ngroups * sizeof(gid_t));
                if (!cpy->groups) {
                        return NULL;
                }
-               memcpy(cpy->groups, tok->groups, tok->ngroups * sizeof(gid_t));
        }
        return cpy;
 }