]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Introduce "ace" helper variable
authorVolker Lendecke <vl@samba.org>
Mon, 5 Aug 2024 11:42:09 +0000 (13:42 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 27 Aug 2024 07:19:32 +0000 (07:19 +0000)
Use "psd->dacl->aces[0]" once instead of 3 times

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
source3/smbd/smb2_nttrans.c

index f61848334ba6ce5f52bd0cb7bf3adedc54b81402..4bff0e42eac46f51696e1a28b89dbb9c060c7562 100644 (file)
@@ -177,6 +177,7 @@ static bool check_smb2_posix_chmod_ace(const struct files_struct *fsp,
                                        struct security_descriptor *psd,
                                        mode_t *pmode)
 {
+       struct security_ace *ace = NULL;
        int cmp;
 
        /*
@@ -203,18 +204,18 @@ static bool check_smb2_posix_chmod_ace(const struct files_struct *fsp,
        if (psd->dacl->num_aces != 1) {
                return false;
        }
+       ace = &psd->dacl->aces[0];
 
-       if (psd->dacl->aces[0].trustee.num_auths != 3) {
+       if (ace->trustee.num_auths != 3) {
                return false;
        }
 
-       cmp = dom_sid_compare_domain(&global_sid_Unix_NFS_Mode,
-                                    &psd->dacl->aces[0].trustee);
+       cmp = dom_sid_compare_domain(&global_sid_Unix_NFS_Mode, &ace->trustee);
        if (cmp != 0) {
                return false;
        }
 
-       *pmode = (mode_t)psd->dacl->aces[0].trustee.sub_auths[2];
+       *pmode = (mode_t)ace->trustee.sub_auths[2];
        *pmode &= (S_IRWXU | S_IRWXG | S_IRWXO);
 
        return true;