mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
befs: Validate length of long symbolic links.
Signed-off-by: Timo Warns <warns@pre-sense.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
b4fd4ae6c6
commit
338d0f0a6f
@ -474,17 +474,22 @@ befs_follow_link(struct dentry *dentry, struct nameidata *nd)
|
|||||||
befs_data_stream *data = &befs_ino->i_data.ds;
|
befs_data_stream *data = &befs_ino->i_data.ds;
|
||||||
befs_off_t len = data->size;
|
befs_off_t len = data->size;
|
||||||
|
|
||||||
befs_debug(sb, "Follow long symlink");
|
if (len == 0) {
|
||||||
|
befs_error(sb, "Long symlink with illegal length");
|
||||||
link = kmalloc(len, GFP_NOFS);
|
|
||||||
if (!link) {
|
|
||||||
link = ERR_PTR(-ENOMEM);
|
|
||||||
} else if (befs_read_lsymlink(sb, data, link, len) != len) {
|
|
||||||
kfree(link);
|
|
||||||
befs_error(sb, "Failed to read entire long symlink");
|
|
||||||
link = ERR_PTR(-EIO);
|
link = ERR_PTR(-EIO);
|
||||||
} else {
|
} else {
|
||||||
link[len - 1] = '\0';
|
befs_debug(sb, "Follow long symlink");
|
||||||
|
|
||||||
|
link = kmalloc(len, GFP_NOFS);
|
||||||
|
if (!link) {
|
||||||
|
link = ERR_PTR(-ENOMEM);
|
||||||
|
} else if (befs_read_lsymlink(sb, data, link, len) != len) {
|
||||||
|
kfree(link);
|
||||||
|
befs_error(sb, "Failed to read entire long symlink");
|
||||||
|
link = ERR_PTR(-EIO);
|
||||||
|
} else {
|
||||||
|
link[len - 1] = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
link = befs_ino->i_data.symlink;
|
link = befs_ino->i_data.symlink;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user