From: number9652 <number9652@yahoo.com>
To: linux-ext4@vger.kernel.org
Subject: [PATCH] libext2fs: ensure validate_entry doesn't read beyond blocksize
Date: Fri, 12 Jun 2009 09:04:32 -0700 (PDT) [thread overview]
Message-ID: <687495.40108.qm@web43515.mail.sp1.yahoo.com> (raw)
ext2fs_validate_entry would read beyond the end of the block to get dirent->rec_len for certain arguments (like if blocksize == final_offset). This patch adds a check so that doesn't happen, and changes the types of the arguments to avoid a compiler warning.
Signed-off-by: Nic Case <number9652@yahoo.com>
diff --git a/e2fsprogs-1.41.5-orig/lib/ext2fs/dir_iterate.c b/e2fsprogs-1.41.5/lib/ext2fs/dir_iterate.c
index 1f8cf8f..6be066c 100644
--- a/e2fsprogs-1.41.5-orig/lib/ext2fs/dir_iterate.c
+++ b/e2fsprogs-1.41.5/lib/ext2fs/dir_iterate.c
@@ -29,13 +29,15 @@
* undeleted entry. Returns 1 if the deleted entry looks valid, zero
* if not valid.
*/
-static int ext2fs_validate_entry(ext2_filsys fs, char *buf, int offset,
- int final_offset)
+static int ext2fs_validate_entry(ext2_filsys fs, char *buf,
+ unsigned int offset,
+ unsigned int final_offset)
{
struct ext2_dir_entry *dirent;
int rec_len;
+ int dirent_min_len = 12;
- while (offset < final_offset) {
+ while (offset < final_offset && offset <= fs->blocksize - dirent_min_len) {
dirent = (struct ext2_dir_entry *)(buf + offset);
rec_len = (dirent->rec_len || fs->blocksize < 65536) ?
dirent->rec_len : 65536;
next reply other threads:[~2009-06-12 16:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-12 16:04 number9652 [this message]
2009-06-29 5:27 ` [PATCH] libext2fs: ensure validate_entry doesn't read beyond blocksize Theodore Tso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=687495.40108.qm@web43515.mail.sp1.yahoo.com \
--to=number9652@yahoo.com \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).