* [PATCH] libext2fs: ensure validate_entry doesn't read beyond blocksize
@ 2009-06-12 16:04 number9652
2009-06-29 5:27 ` Theodore Tso
0 siblings, 1 reply; 2+ messages in thread
From: number9652 @ 2009-06-12 16:04 UTC (permalink / raw)
To: linux-ext4
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;
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] libext2fs: ensure validate_entry doesn't read beyond blocksize
2009-06-12 16:04 [PATCH] libext2fs: ensure validate_entry doesn't read beyond blocksize number9652
@ 2009-06-29 5:27 ` Theodore Tso
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Tso @ 2009-06-29 5:27 UTC (permalink / raw)
To: number9652; +Cc: linux-ext4
On Fri, Jun 12, 2009 at 09:04:32AM -0700, number9652 wrote:
>
> 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>
Applied. In the future, please line-wrap the body of the commit
message at 72-75 characters.
I also lined up the arguments to ext2fs_validate_entry on the
continuation line, and used a CPP macro instead of an automatic
variable for dirent_min_length.
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-06-29 5:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-12 16:04 [PATCH] libext2fs: ensure validate_entry doesn't read beyond blocksize number9652
2009-06-29 5:27 ` Theodore Tso
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).