[syslinux] [PATCH] add additional checks to ext2 loader
Frediano Ziglio
frediano.ziglio at citrix.com
Thu Aug 2 01:32:36 PDT 2012
Check if some pointers are not NULL due to read errors or other problems
Signed-off-by: Frediano Ziglio <frediano.ziglio at citrix.com>
---
core/fs/ext2/ext2.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c
index bddde8d..8f0f2a4 100644
--- a/core/fs/ext2/ext2.c
+++ b/core/fs/ext2/ext2.c
@@ -139,6 +139,8 @@ ext2_get_inode(struct fs_info *fs, int inr)
block_off = inode_offset % EXT2_INODES_PER_BLOCK(fs);
data = get_cache(fs->fs_dev, block_num);
+ if (!data)
+ return NULL;
return (const struct ext2_inode *)
(data + block_off * EXT2_SB(fs)->s_inode_size);
@@ -164,7 +166,7 @@ static struct inode *ext2_iget_by_inr(struct fs_info *fs, uint32_t inr)
struct inode *inode;
e_inode = ext2_get_inode(fs, inr);
- if (!(inode = alloc_inode(fs, inr, sizeof(struct ext2_pvt_inode))))
+ if (!e_inode || !(inode = alloc_inode(fs, inr, sizeof(struct ext2_pvt_inode))))
return NULL;
fill_inode(inode, e_inode);
--
1.7.5.4
More information about the Syslinux
mailing list