[OpenBIOS] [PATCH] grubfs: don't try to read a file beyond its end
Aurelien Jarno
aurelien at aurel32.net
Fri Jan 9 20:24:50 CET 2009
Yaboot relies on the read function from openbios to stop reading at the
end of a file. This patch makes sure to not read beyond the end of the
file. This fixes the boot of debian-installer using a CD-ROM.
Signed-off-by: Aurelien Jarno <aurelien at aurel32.net>
diff --git a/fs/grubfs/grubfs_fs.c b/fs/grubfs/grubfs_fs.c
index f172b75..588d677 100644
--- a/fs/grubfs/grubfs_fs.c
+++ b/fs/grubfs/grubfs_fs.c
@@ -161,6 +161,9 @@ grubfs_file_read( file_desc_t *fd, void *buf, size_t count )
filepos=file->pos;
filemax=file->len;
+ if (count > filemax - filepos)
+ count = filemax - filepos;
+
ret=curfs->fsys->read_func(buf, count);
file->pos=filepos;
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32 at debian.org | aurelien at aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
More information about the OpenBIOS
mailing list