Skip to contentSkip to conversation

fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPE

PATCH New Gerard Koskamp 3 participants 3 messages Oct 30, 2020 – Nov 20, 2020 SquashFS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPE

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

CC Joao Marcos Costa <[email protected]>

---

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

fs/squashfs/sqfs_inode.c +0 -0
index 14d70cf..0983974 100644
@@ -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

#1 lore raw

PATCH 1/1 fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPE

Tested-by Joao Marcos Costa <[email protected]>

Em sex., 30 de out. de 2020 ?s 10:42, Gerard Koskamp < [email protected]> escreveu:

Quoted 42 lines

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

CC Joao Marcos Costa <[email protected]>

---

 fs/squashfs/sqfs_inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/squashfs/sqfs_inode.c +1 -1
index 14d70cf..0983974 100644
@@ -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;
fs/squashfs/sqfs_inode.c +1 -1
@@ -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

Signature · 5 lines
Atenciosamente,
Jo?o Marcos Costa

www.linkedin.com/in/jmarcoscosta/
https://github.com/jmarcoscosta
#2 lore raw

PATCH 1/1 fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPE

In reply to Gerard Koskamp
Quoted 11 lines · Gerard Koskamp

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

Applied to u-boot/master, thanks!

Signature · 8 lines
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>