posix_acls: clarify loop condition code, removing unneeded counter variable.
authorMichael Adam <obnox@samba.org>
Thu, 27 Mar 2008 09:09:24 +0000 (10:09 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 27 Mar 2008 09:09:24 +0000 (10:09 +0100)
Coverity ID 545 falsely classified this as a NULL dereferencing bug.
By putting the loop of walking the list of aces more naturely not using
additional counters, it becomes much more obvious that it is not entered
when dir_ace == NULL.

The same modifications are done for the file_ace loop.

Michael
(This used to be commit 6dab6cf0647d7db01e5e472f8b5cf21395b7dbf0)

source3/smbd/posix_acls.c

index f60329a039a95b0c2a2d2550853205aa4afb5bc3..c3c9d2e60c4f1e031f494deb62943800cd6e2131 100644 (file)
@@ -2882,7 +2882,6 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn,
                {
                        canon_ace *ace;
                        enum security_ace_type nt_acl_type;
-                       int i;
 
                        if (nt4_compatible_acls() && dir_ace) {
                                /*
@@ -2948,9 +2947,7 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn,
                         * Create the NT ACE list from the canonical ace lists.
                         */
 
-                       ace = file_ace;
-
-                       for (i = 0; i < num_acls; i++, ace = ace->next) {
+                       for (ace = file_ace; ace != NULL; ace = ace->next) {
                                SEC_ACCESS acc;
 
                                acc = map_canon_ace_perms(SNUM(conn),
@@ -2977,9 +2974,7 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn,
                                                acc, 0);
                        }
 
-                       ace = dir_ace;
-
-                       for (i = 0; i < num_def_acls; i++, ace = ace->next) {
+                       for (ace = dir_ace; ace != NULL; ace = ace->next) {
                                SEC_ACCESS acc;
 
                                acc = map_canon_ace_perms(SNUM(conn),