diff mbox

[U-Boot] fs: ext4: fix symlink read function

Message ID 1461775250-29762-1-git-send-email-sr@denx.de
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Stefan Roese April 27, 2016, 4:40 p.m. UTC
From: Ronald Zachariah <rozachar@cisco.com>

The function ext4fs_read_symlink was unable to handle a symlink
which had target name of exactly 60 characters.

Signed-off-by: Ronald Zachariah <rozachar@cisco.com>
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Tom Rini <trini@konsulko.com>
---
 fs/ext4/ext4_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Warren April 27, 2016, 5:34 p.m. UTC | #1
On 04/27/2016 10:40 AM, Stefan Roese wrote:
> From: Ronald Zachariah <rozachar@cisco.com>
>
> The function ext4fs_read_symlink was unable to handle a symlink
> which had target name of exactly 60 characters.

Reviewed-by: Stephen Warren <swarren@nvidia.com>

This seems to match how the Linux kernel encodes symlinks.

> -	if (__le32_to_cpu(diro->inode.size) <= 60) {
> +	if (__le32_to_cpu(diro->inode.size) < 60) {

It'd be nice if "60" was replaced with sizeof(diro->inode.b.symlink), 
but that's probably a topic for a different patch.
diff mbox

Patch

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 84fba76..868c281 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -2040,7 +2040,7 @@  static char *ext4fs_read_symlink(struct ext2fs_node *node)
 	if (!symlink)
 		return 0;
 
-	if (__le32_to_cpu(diro->inode.size) <= 60) {
+	if (__le32_to_cpu(diro->inode.size) < 60) {
 		strncpy(symlink, diro->inode.b.symlink,
 			 __le32_to_cpu(diro->inode.size));
 	} else {