Skip to contentSkip to conversation

libext2fs : Fix the return values for ino=0 in ext2fs_read_inode_full() if inode cache has been flushed.

PATCH Applied Manish Katiyar 2 participants 3 messages Jul 12, 2008 – Jul 19, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libext2fs : Fix the return values for ino=0 in ext2fs_read_inode_full() if inode cache has been flushed.

Hi Ted,

It looks like the right place to check for ino=0 in ext2fs_read_inode_full() is before creating the inode cache, otherwise since we set icache[i].ino = 0 in create_icache(), it will match the loop below and thus we return a wrong value. Below patch fixes it.

==========================================================================

---
 lib/ext2fs/inode.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
lib/ext2fs/inode.c +0 -0
index 8908423..a08cb40 100644
@@ -536,6 +536,8 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs,

ext2_ino_t ino,
if (retval != EXT2_ET_CALLBACK_NOTHANDLED)
return retval;
}
+ if ((ino == 0) || (ino > fs->super->s_inodes_count))
+ return EXT2_ET_BAD_INODE_NUM;
/* Create inode cache if not present */
if (!fs->icache) {
retval = create_icache(fs);
@@ -552,8 +554,6 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
}
}
}
- if ((ino == 0) || (ino > fs->super->s_inodes_count))
- return EXT2_ET_BAD_INODE_NUM;
if (fs->flags & EXT2_FLAG_IMAGE_FILE) {
inodes_per_block = fs->blocksize / EXT2_INODE_SIZE(fs->super); block_nr = fs->image_header->offset_inode / fs->blocksize;

Signature · 7 lines
1.5.4.3


=====================================================================

Thanks -
Manish
#1 lore raw
Quoted 39 lines · Manish Katiyar

Hi Ted,

It looks like the right place to check for ino=0 in ext2fs_read_inode_full() is before creating the inode cache, otherwise since we set icache[i].ino = 0 in create_icache(), it will match the loop below and thus we return a wrong value. Below patch fixes it.

==========================================================================

---
 lib/ext2fs/inode.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
lib/ext2fs/inode.c +2 -0
index 8908423..a08cb40 100644
@@ -536,6 +536,8 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs,
 ext2_ino_t ino,
               if (retval != EXT2_ET_CALLBACK_NOTHANDLED)
                       return retval;
       }
+       if ((ino == 0) || (ino > fs->super->s_inodes_count))
+               return EXT2_ET_BAD_INODE_NUM;
       /* Create inode cache if not present */
       if (!fs->icache) {
               retval = create_icache(fs);
lib/ext2fs/inode.c +0 -2
@@ -552,8 +554,6 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs,
 ext2_ino_t ino,
                       }
               }
       }
-       if ((ino == 0) || (ino > fs->super->s_inodes_count))
-               return EXT2_ET_BAD_INODE_NUM;
       if (fs->flags & EXT2_FLAG_IMAGE_FILE) {
               inodes_per_block = fs->blocksize / EXT2_INODE_SIZE(fs->super);
               block_nr = fs->image_header->offset_inode / fs->blocksize;
Quoted 6 lines

--
1.5.4.3

=====================================================================

Any ack/nack on this ?

Quoted 3 lines

Thanks -
Manish

Applied
#2 lore raw
Quoted 1 line · Manish Katiyar

Any ack/nack on this ?

Applied, sorry for forgetting to ack it.

- Ted