From 6beba1e5de2cabdeb45bb7c3ea5fd8e532508275 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 3 May 1995 22:03:50 +0000 Subject: Formerly dir.c.~10~ --- ext2fs/dir.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ext2fs/dir.c b/ext2fs/dir.c index afdd23dc..cbb58d91 100644 --- a/ext2fs/dir.c +++ b/ext2fs/dir.c @@ -2,6 +2,8 @@ Copyright (C) 1994, 1995 Free Software Foundation, Inc. + Converted for ext2fs by Miles Bader + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at @@ -870,12 +872,29 @@ diskfs_get_directs (struct node *dp, i++; } + if (entryp->rec_len == 0) + { + ext2_warning ("diskfs_get_directs", + "Zero length directory entry: inode: %d offset: %ld", + dp->dn->number, + blkno * DIRBLKSIZ + bufp - buf); + return EIO; + } + bufp += entryp->rec_len; if (bufp - buf == DIRBLKSIZ) { blkno++; bufvalid = 0; } + else if (bufp - buf > DIRBLKSIZ) + { + ext2_warning ("diskfs_get_directs", + "Directory entry too long: inode: %d offset: %ld", + dp->dn->number, + blkno * DIRBLKSIZ + bufp - buf - entryp->rec_len); + return EIO; + } } /* We've copied all we can. If we allocated our own array -- cgit v1.2.3