diff options
author | H. Peter Anvin <hpa@zytor.com> | 2010-02-16 13:57:30 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-02-16 13:57:30 -0800 |
commit | cb2bde2a1f8b71fe043b57fc60579a358b4b9a13 (patch) | |
tree | fa5b84d6b252fb11f7cd3dc570fa5c134840fe89 | |
parent | f94acac11bb41676ec47d457317eb027e90bb441 (diff) | |
download | syslinux-cb2bde2a1f8b71fe043b57fc60579a358b4b9a13.tar.gz |
ext2: a zero block number is actually legit
It may not happen in normal operation, but a zero block value is legit
and means an all-zero block. For anything which uses the cache, we
have dealt with that by always keeping a zero block in the cache.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | core/fs/ext2/ext2.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c index bc758249..52543407 100644 --- a/core/fs/ext2/ext2.c +++ b/core/fs/ext2/ext2.c @@ -184,8 +184,7 @@ ext2_find_entry(struct fs_info *fs, struct inode *inode, const char *dname) size_t dname_len = strlen(dname); while (i < inode->size) { - if (!(block = ext2_bmap(inode, index++))) - return NULL; + block = ext2_bmap(inode, index++); data = get_cache(fs->fs_dev, block); offset = 0; maxoffset = min(BLOCK_SIZE(fs), i-inode->size); @@ -323,8 +322,10 @@ static struct dirent * ext2_readdir(struct file *file) block_t index = file->offset >> fs->block_shift; block_t block; - if (!(block = ext2_bmap(inode, index))) - return NULL; + if (file->offset >= inode->size) + return NULL; /* End of file */ + + block = ext2_bmap(inode, index); data = get_cache(fs->fs_dev, block); de = (const struct ext2_dir_entry *) |