Date: Sat, 3 Jun 2017 22:39:50 +0000 (UTC) From: Conrad Meyer <cem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319558 - head/sys/fs/ext2fs Message-ID: <201706032239.v53Mdo5q060468@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: cem Date: Sat Jun 3 22:39:50 2017 New Revision: 319558 URL: https://svnweb.freebsd.org/changeset/base/319558 Log: 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 Modified: head/sys/fs/ext2fs/ext2_acl.c Modified: head/sys/fs/ext2fs/ext2_acl.c ============================================================================== --- head/sys/fs/ext2fs/ext2_acl.c Sat Jun 3 22:30:30 2017 (r319557) +++ head/sys/fs/ext2fs/ext2_acl.c Sat Jun 3 22:39:50 2017 (r319558) @@ -127,13 +127,18 @@ ext2_sync_inode_from_acl(struct acl *acl, struct inode 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,21 +254,20 @@ 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; - } + } else if (error != 0) + 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); - 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706032239.v53Mdo5q060468>