diff mbox

[v2,7/9] btrfs: Check namelen before read in 'btrfs_get_name'

Message ID 20170601085716.25898-8-suy.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Su Yue June 1, 2017, 8:57 a.m. UTC
Call 'btrfs_is_namelen_valid' in 'btrfs_get_name'.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
 fs/btrfs/export.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 87144c9f9593..213e971e8dcf 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -282,6 +282,11 @@  static int btrfs_get_name(struct dentry *parent, char *name,
 		name_len = btrfs_inode_ref_name_len(leaf, iref);
 	}
 
+	ret = btrfs_is_namelen_valid(leaf, path->slots[0], name_ptr, name_len);
+	if (!ret) {
+		btrfs_free_path(path);
+		return -EIO;
+	}
 	read_extent_buffer(leaf, name, name_ptr, name_len);
 	btrfs_free_path(path);