aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/ext2fs/ext2_acl.c
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2017-06-03 22:39:50 +0000
committerConrad Meyer <cem@FreeBSD.org>2017-06-03 22:39:50 +0000
commit109f344bb60561da5de8e9e523c9c647ccfacc04 (patch)
treef164a6dbf624e4df648b02cfddf92667f1902889 /sys/fs/ext2fs/ext2_acl.c
parenta8b9a63980dadae90e4602a948f10ee0b7da1f5f (diff)
ext2fs(4): Fix a null dererence and clean an unclear switch
Coverity warned that the switch statement fell through. While this was intentional, the pattern wasn't especially clear. I just changed it to a conventional if pattern. Reported by: Coverity CIDs: 1375851 (false positive), 1375853 Sponsored by: Dell EMC Isilon
Notes
Notes: svn path=/head/; revision=319558
Diffstat (limited to 'sys/fs/ext2fs/ext2_acl.c')
-rw-r--r--sys/fs/ext2fs/ext2_acl.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/sys/fs/ext2fs/ext2_acl.c b/sys/fs/ext2fs/ext2_acl.c
index afea23da933d..0f47c2981f94 100644
--- a/sys/fs/ext2fs/ext2_acl.c
+++ b/sys/fs/ext2fs/ext2_acl.c
@@ -127,13 +127,18 @@ ext2_sync_inode_from_acl(struct acl *acl, struct inode *ip)
static int
ext4_acl_from_disk(char *value, size_t size, struct acl *acl)
{
- const char *end = value + size;
+ const char *end;
int n, count, s;
+ if (value == NULL)
+ return (EINVAL);
+
+ end = value + size;
+
if (((struct ext2_acl_header *)value)->a_version != EXT4_ACL_VERSION)
return (EINVAL);
- if (!value || size < sizeof(struct ext2_acl_header))
+ if (size < sizeof(struct ext2_acl_header))
return (EINVAL);
s = size - sizeof(struct ext2_acl_header);
@@ -230,8 +235,7 @@ ext2_getacl_posix1e(struct vop_getacl_args *ap)
error = vn_extattr_get(ap->a_vp, IO_NODELOCKED, attrnamespace, attrname,
&len, value, ap->a_td);
- switch (error) {
- case ENOATTR:
+ if (error == ENOATTR) {
switch (ap->a_type) {
case ACL_TYPE_ACCESS:
ap->a_aclp->acl_cnt = 3;
@@ -250,22 +254,21 @@ ext2_getacl_posix1e(struct vop_getacl_args *ap)
ap->a_aclp->acl_cnt = 0;
break;
}
- case 0:
- if (!error) {
- error = ext4_acl_from_disk(value, len, ap->a_aclp);
- if (error)
- goto out;
- }
-
- if (error == ENOATTR)
- error = 0;
+ } else if (error != 0)
+ goto out;
- if (ap->a_type == ACL_TYPE_ACCESS)
- ext2_sync_acl_from_inode(VTOI(ap->a_vp), ap->a_aclp);
- default:
- break;
+ if (!error) {
+ error = ext4_acl_from_disk(value, len, ap->a_aclp);
+ if (error)
+ goto out;
}
+ if (error == ENOATTR)
+ error = 0;
+
+ if (ap->a_type == ACL_TYPE_ACCESS)
+ ext2_sync_acl_from_inode(VTOI(ap->a_vp), ap->a_aclp);
+
out:
free(value, M_TEMP);
return (error);