public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPE
@ 2020-10-30 13:41 Gerard Koskamp
  2020-10-30 17:48 ` João Marcos Costa
  2020-11-20  1:36 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Gerard Koskamp @ 2020-10-30 13:41 UTC (permalink / raw)
  To: u-boot

I've created a squashfs file system with Yocto (it use squashfs-tools)
and u-boot command sqfsls give the error:'Error while searching inode:
unknown type.'
After some digging in the code I found that the index is off by 1.
This patch fix this issue and I can successful use the sqfsls command.
After search for the squashfs format I found a link talk about a
similar issue but this time in the documentation. The link is:
https://github.com/AgentD/squashfs-tools-ng/commit/e6588526838caece9529

Signed-off-by: Gerard Koskamp <gerard.koskamp@nedap.com>
CC: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
---

?fs/squashfs/sqfs_inode.c | 4 ++--
?1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/squashfs/sqfs_inode.c b/fs/squashfs/sqfs_inode.c
index 14d70cf..0983974 100644
--- a/fs/squashfs/sqfs_inode.c
+++ b/fs/squashfs/sqfs_inode.c
@@ -49,7 +49,7 @@ int sqfs_inode_size(struct squashfs_base_inode *inode, u32 blk_size)
?			return sizeof(*ldir);
?
?		di = ldir->index;
-		while (l < i_count + 1) {
+		while (l < i_count) {
?			sz = get_unaligned_le32(&di->size) + 1;
?			index_list_size += sz;
?			di = (void *)di + sizeof(*di) + sz;
@@ -57,7 +57,7 @@ int sqfs_inode_size(struct squashfs_base_inode *inode, u32 blk_size)
?		}
?
?		return sizeof(*ldir) + index_list_size +
-			(i_count + 1) * SQFS_DIR_INDEX_BASE_LENGTH;
+			i_count * SQFS_DIR_INDEX_BASE_LENGTH;
?	}
?
?	case SQFS_LREG_TYPE: {
--?
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPE
  2020-10-30 13:41 [PATCH] fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPE Gerard Koskamp
@ 2020-10-30 17:48 ` João Marcos Costa
  2020-11-20  1:36 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: João Marcos Costa @ 2020-10-30 17:48 UTC (permalink / raw)
  To: u-boot

Tested-by Joao Marcos Costa <jmcosta944@gmail.com>

Em sex., 30 de out. de 2020 ?s 10:42, Gerard Koskamp <
gerard.koskamp@nedap.com> escreveu:

> I've created a squashfs file system with Yocto (it use squashfs-tools)
> and u-boot command sqfsls give the error:'Error while searching inode:
> unknown type.'
> After some digging in the code I found that the index is off by 1.
> This patch fix this issue and I can successful use the sqfsls command.
> After search for the squashfs format I found a link talk about a
> similar issue but this time in the documentation. The link is:
> https://github.com/AgentD/squashfs-tools-ng/commit/e6588526838caece9529
>
> Signed-off-by: Gerard Koskamp <gerard.koskamp@nedap.com>
> CC: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
> ---
>
>  fs/squashfs/sqfs_inode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/squashfs/sqfs_inode.c b/fs/squashfs/sqfs_inode.c
> index 14d70cf..0983974 100644
> --- a/fs/squashfs/sqfs_inode.c
> +++ b/fs/squashfs/sqfs_inode.c
> @@ -49,7 +49,7 @@ int sqfs_inode_size(struct squashfs_base_inode *inode,
> u32 blk_size)
>                         return sizeof(*ldir);
>
>                 di = ldir->index;
> -               while (l < i_count + 1) {
> +               while (l < i_count) {
>                         sz = get_unaligned_le32(&di->size) + 1;
>                         index_list_size += sz;
>                         di = (void *)di + sizeof(*di) + sz;
> @@ -57,7 +57,7 @@ int sqfs_inode_size(struct squashfs_base_inode *inode,
> u32 blk_size)
>                 }
>
>                 return sizeof(*ldir) + index_list_size +
> -                       (i_count + 1) * SQFS_DIR_INDEX_BASE_LENGTH;
> +                       i_count * SQFS_DIR_INDEX_BASE_LENGTH;
>         }
>
>         case SQFS_LREG_TYPE: {
> --
> 2.7.4



-- 
Atenciosamente,
Jo?o Marcos Costa

www.linkedin.com/in/jmarcoscosta/
https://github.com/jmarcoscosta

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPE
  2020-10-30 13:41 [PATCH] fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPE Gerard Koskamp
  2020-10-30 17:48 ` João Marcos Costa
@ 2020-11-20  1:36 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2020-11-20  1:36 UTC (permalink / raw)
  To: u-boot

On Fri, Oct 30, 2020 at 01:41:58PM +0000, Gerard Koskamp wrote:

> I've created a squashfs file system with Yocto (it use squashfs-tools)
> and u-boot command sqfsls give the error:'Error while searching inode:
> unknown type.'
> After some digging in the code I found that the index is off by 1.
> This patch fix this issue and I can successful use the sqfsls command.
> After search for the squashfs format I found a link talk about a
> similar issue but this time in the documentation. The link is:
> https://github.com/AgentD/squashfs-tools-ng/commit/e6588526838caece9529
> 
> Signed-off-by: Gerard Koskamp <gerard.koskamp@nedap.com>
> Tested-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201119/0f5d0df4/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-20  1:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-30 13:41 [PATCH] fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPE Gerard Koskamp
2020-10-30 17:48 ` João Marcos Costa
2020-11-20  1:36 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox