diff options
Diffstat (limited to 'fs/squashfs/xattr_id.c')
-rw-r--r-- | fs/squashfs/xattr_id.c | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/fs/squashfs/xattr_id.c b/fs/squashfs/xattr_id.c index 05385dbe1465..c89607d690c4 100644 --- a/fs/squashfs/xattr_id.c +++ b/fs/squashfs/xattr_id.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
3 | * | 3 | * |
4 | * Copyright (c) 2010 | 4 | * Copyright (c) 2010 |
5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
@@ -67,34 +67,29 @@ __le64 *squashfs_read_xattr_id_table(struct super_block *sb, u64 start, | |||
67 | u64 *xattr_table_start, int *xattr_ids) | 67 | u64 *xattr_table_start, int *xattr_ids) |
68 | { | 68 | { |
69 | unsigned int len; | 69 | unsigned int len; |
70 | __le64 *xid_table; | 70 | struct squashfs_xattr_id_table *id_table; |
71 | struct squashfs_xattr_id_table id_table; | 71 | |
72 | int err; | 72 | id_table = squashfs_read_table(sb, start, sizeof(*id_table)); |
73 | if (IS_ERR(id_table)) | ||
74 | return (__le64 *) id_table; | ||
75 | |||
76 | *xattr_table_start = le64_to_cpu(id_table->xattr_table_start); | ||
77 | *xattr_ids = le32_to_cpu(id_table->xattr_ids); | ||
78 | kfree(id_table); | ||
79 | |||
80 | /* Sanity check values */ | ||
81 | |||
82 | /* there is always at least one xattr id */ | ||
83 | if (*xattr_ids == 0) | ||
84 | return ERR_PTR(-EINVAL); | ||
85 | |||
86 | /* xattr_table should be less than start */ | ||
87 | if (*xattr_table_start >= start) | ||
88 | return ERR_PTR(-EINVAL); | ||
73 | 89 | ||
74 | err = squashfs_read_table(sb, &id_table, start, sizeof(id_table)); | ||
75 | if (err < 0) { | ||
76 | ERROR("unable to read xattr id table\n"); | ||
77 | return ERR_PTR(err); | ||
78 | } | ||
79 | *xattr_table_start = le64_to_cpu(id_table.xattr_table_start); | ||
80 | *xattr_ids = le32_to_cpu(id_table.xattr_ids); | ||
81 | len = SQUASHFS_XATTR_BLOCK_BYTES(*xattr_ids); | 90 | len = SQUASHFS_XATTR_BLOCK_BYTES(*xattr_ids); |
82 | 91 | ||
83 | TRACE("In read_xattr_index_table, length %d\n", len); | 92 | TRACE("In read_xattr_index_table, length %d\n", len); |
84 | 93 | ||
85 | /* Allocate xattr id lookup table indexes */ | 94 | return squashfs_read_table(sb, start + sizeof(*id_table), len); |
86 | xid_table = kmalloc(len, GFP_KERNEL); | ||
87 | if (xid_table == NULL) { | ||
88 | ERROR("Failed to allocate xattr id index table\n"); | ||
89 | return ERR_PTR(-ENOMEM); | ||
90 | } | ||
91 | |||
92 | err = squashfs_read_table(sb, xid_table, start + sizeof(id_table), len); | ||
93 | if (err < 0) { | ||
94 | ERROR("unable to read xattr id index table\n"); | ||
95 | kfree(xid_table); | ||
96 | return ERR_PTR(err); | ||
97 | } | ||
98 | |||
99 | return xid_table; | ||
100 | } | 95 | } |