6787376 chmod core dump by SIGBUS while removing ACE recursively
authorRenaud Manus <Renaud.Manus@Sun.COM>
Mon, 02 Feb 2009 14:49:51 +0000
changeset 8672 1a4716fc81f2
parent 8671 d3ec1a19966c
child 8673 c3b43e751053
6787376 chmod core dump by SIGBUS while removing ACE recursively
usr/src/lib/libsec/common/aclutils.c
--- a/usr/src/lib/libsec/common/aclutils.c	Mon Feb 02 09:20:33 2009 +0000
+++ b/usr/src/lib/libsec/common/aclutils.c	Mon Feb 02 14:49:51 2009 +0000
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -509,11 +509,18 @@
 			match = acl_match(acl_entry, remove_entry);
 			if (match == 0)  {
 				found++;
+
+				/* avoid memmove if last entry */
+				if (acl->acl_cnt == (j + 1)) {
+					acl->acl_cnt--;
+					break;
+				}
+
 				start = (char *)acl_entry +
 				    acl->acl_entry_size;
 				(void) memmove(acl_entry, start,
 				    acl->acl_entry_size *
-				    acl->acl_cnt-- - (j + 1));
+				    (acl->acl_cnt-- - (j + 1)));
 
 				if (flag == ACL_REMOVE_FIRST)
 					break;