diff options
author | Bruce Evans <bde@FreeBSD.org> | 1997-03-15 16:49:51 +0000 |
---|---|---|
committer | Bruce Evans <bde@FreeBSD.org> | 1997-03-15 16:49:51 +0000 |
commit | c24b67b188651a9debc48a0b120fe1792dc2eb1d (patch) | |
tree | 6a22d9dd06d2b31b5464f9009bc5033943ebbbfd /sys | |
parent | fd27ec2d05439a1899600fb84f6b147f8dd3b255 (diff) | |
download | src-c24b67b188651a9debc48a0b120fe1792dc2eb1d.tar.gz src-c24b67b188651a9debc48a0b120fe1792dc2eb1d.zip |
Don't attempt to read past EOF.
Saved enough bytes to make room for this bloat (testing poff < inode.i_size
takes 56 bytes!) by copying fs to a local variable.
Notes
Notes:
svn path=/head/; revision=23905
Diffstat (limited to 'sys')
-rw-r--r-- | sys/i386/boot/biosboot/sys.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/i386/boot/biosboot/sys.c b/sys/i386/boot/biosboot/sys.c index 4ac397838069..2ad469455d1c 100644 --- a/sys/i386/boot/biosboot/sys.c +++ b/sys/i386/boot/biosboot/sys.c @@ -24,7 +24,7 @@ * the rights to redistribute these changes. * * from: Mach, Revision 2.2 92/04/04 11:36:34 rpd - * $Id$ + * $Id: sys.c,v 1.18 1997/02/22 09:30:14 peter Exp $ */ #include "boot.h" @@ -73,12 +73,14 @@ read(char *buffer, int count) { int logno, off, size; int cnt2, bnum2; + struct fs *fs_copy; - while (count) { - off = blkoff(fs, poff); - logno = lblkno(fs, poff); - cnt2 = size = blksize(fs, &inode, logno); - bnum2 = fsbtodb(fs, block_map(logno)) + boff; + while (count > 0 && poff < inode.i_size) { + fs_copy = fs; + off = blkoff(fs_copy, poff); + logno = lblkno(fs_copy, poff); + cnt2 = size = blksize(fs_copy, &inode, logno); + bnum2 = fsbtodb(fs_copy, block_map(logno)) + boff; if ( (!off) && (size <= count)) { devread(buffer, bnum2, cnt2); } else { |