[PATCH] vfs/xattr: strengthen error check to avoid unexpected result

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The variable error is ssize_t, which is signed and will
cast to unsigned when comapre with variable size, so add
a check to avoid unexpected result in case of negative
value of error.

Signed-off-by: Chengguang Xu <cgxu519@xxxxxxxxxxxx>
---
 fs/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xattr.c b/fs/xattr.c
index e13265e65871..9d0f12682c86 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -356,7 +356,7 @@ vfs_listxattr(struct dentry *dentry, char *list, size_t size)
 		error = inode->i_op->listxattr(dentry, list, size);
 	} else {
 		error = security_inode_listsecurity(inode, list, size);
-		if (size && error > size)
+		if (error >= 0 && size && error > size)
 			error = -ERANGE;
 	}
 	return error;
-- 
2.20.1






[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux