}
}
- /* Otherwise, we have to have matching UIDs or GIDs. */
- if (updated_tag == ACL_USER) {
+ /* Second, they could have matching UIDs. We don't really need to
+ check both tags here, since we know that they're equal. However,
+ clang-tidy can't figure that out, and the redundant equality
+ check prevents it from complaining about a potential null pointer
+ dereference. */
+ if (updated_tag == ACL_USER && existing_tag == ACL_USER) {
qualifiers_match = ( *((uid_t*)existing_qualifier)
==
*((uid_t*)updated_qualifier) );
}
- else if (updated_tag == ACL_GROUP) {
+
+ /* Third, they could have matching GIDs. See above for why
+ we check the redundant condition existing_tag == ACL_GROUP. */
+ if (updated_tag == ACL_GROUP && existing_tag == ACL_GROUP) {
qualifiers_match = ( *((gid_t*)existing_qualifier)
==
*((gid_t*)updated_qualifier) );
goto cleanup;
}
- result = ACL_SUCCESS;
+ result = ACL_SUCCESS;
goto cleanup;
}
}