summaryrefslogtreecommitdiff
path: root/sys/msdosfs/msdosfs_fat.c
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-10-22 19:04:24 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-10-22 19:04:24 +0000
commitda83f0b9bfa8df955a54a117dc1fe674e6e27f77 (patch)
tree08237c6c66ee859b28ec70404d73ae3ad3bbe575 /sys/msdosfs/msdosfs_fat.c
parent6e363212d16d26425498972bb2e01ed7035bb463 (diff)
from netbsd:
Fix a panic that occurred when trying to traverse a corrupt msdosfs filesystem. With this particular corruption, the code in pcbmap() would compute an offset into an array that was way out of bounds, so check the bounds before trying to access and return an error if the offset would be out of bounds.
Diffstat (limited to 'sys/msdosfs/msdosfs_fat.c')
-rw-r--r--sys/msdosfs/msdosfs_fat.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/msdosfs/msdosfs_fat.c b/sys/msdosfs/msdosfs_fat.c
index 6cda019aee4..1dadb7ab3e5 100644
--- a/sys/msdosfs/msdosfs_fat.c
+++ b/sys/msdosfs/msdosfs_fat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_fat.c,v 1.11 2002/03/14 01:27:09 millert Exp $ */
+/* $OpenBSD: msdosfs_fat.c,v 1.12 2003/10/22 19:04:23 tedu Exp $ */
/* $NetBSD: msdosfs_fat.c,v 1.26 1997/10/17 11:24:02 ws Exp $ */
/*-
@@ -232,6 +232,11 @@ pcbmap(dep, findcn, bnp, cnp, sp)
bp_bn = bn;
}
prevcn = cn;
+ if (bo >= bsize) {
+ if (bp)
+ brelse(bp);
+ return (EIO);
+ }
if (FAT32(pmp))
cn = getulong(&bp->b_data[bo]);
else