mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-25 16:49:23 +00:00
fix an overrun bug in ffs and typos in testload.
This commit is contained in:
1 parent
cb145227ae
commit
f0ef2907eb
4 files changed
+50
-11
No files matched your search
@@ -1,3 +1,18 @@
|
||||
1999-09-06 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
|
||||
|
||||
* stage2/builtins.c (testload_func): Fix the typos: 0x2000000 ->
|
||||
0x200000 and 0x3000000 -> 0x300000.
|
||||
|
||||
1999-09-06 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
|
||||
|
||||
From Hisazumi Kenji <nel@soraneko.com>:
|
||||
* stage2/fsys_ffs.c (mapblock_offset): New variable.
|
||||
(mapblock_bsize): Likewise.
|
||||
(MAPBUF): New macro.
|
||||
(MAPBUF_LEN): Likewise.
|
||||
(ffs_mount): Set MAPBLOCK_OFFSET to -1.
|
||||
(block_map): Added partial read support.
|
||||
|
||||
1999-09-06 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
|
||||
|
||||
* stage2/cmdline.c (find_command): If COMMAND is less than
|
||||
|
||||
@@ -14,6 +14,7 @@ Dan J. Walters <djw@cs.utexas.edu>
|
||||
Edward Killips <ekillips@triton.net>
|
||||
Eric Hanchrow <erich@microsoft.com>
|
||||
Heiko Schroeder <heiko@pool.informatik.rwth-aachen.de>
|
||||
Hisazumi Kenji <nel@soraneko.com>
|
||||
Jochen Hoenicke <jochen@gnu.org>
|
||||
Klaus Reichl <klaus.reichl@alcatel.at>
|
||||
Kunihiro Ishiguro <kunihiro@zebra.org>
|
||||
|
||||
+2
-2
@@ -1244,8 +1244,8 @@ testload_func (char *arg, int flags)
|
||||
*((int *) RAW_ADDR (0x30000c)));
|
||||
|
||||
for (i = 0; i < 0x10ac0; i++)
|
||||
if (*((unsigned char *) RAW_ADDR (0x2000000 + i))
|
||||
!= *((unsigned char *) RAW_ADDR (0x3000000 + i)))
|
||||
if (*((unsigned char *) RAW_ADDR (0x200000 + i))
|
||||
!= *((unsigned char *) RAW_ADDR (0x300000 + i)))
|
||||
break;
|
||||
|
||||
grub_printf ("Max is 0x10ac0: i=0x%x, filepos=0x%x\n", i, filepos);
|
||||
|
||||
+32
-9
@@ -67,11 +67,14 @@
|
||||
|
||||
/* used for filesystem map blocks */
|
||||
static int mapblock;
|
||||
static int mapblock_offset;
|
||||
static int mapblock_bsize;
|
||||
|
||||
/* pointer to superblock */
|
||||
#define SUPERBLOCK ((struct fs *) ( FSYS_BUF + 8192 ))
|
||||
#define INODE ((struct icommon *) ( FSYS_BUF + 16384 ))
|
||||
#define MAPBUF ( FSYS_BUF + 24576 )
|
||||
#define MAPBUF_LEN 8192
|
||||
|
||||
|
||||
int
|
||||
@@ -87,6 +90,7 @@ ffs_mount (void)
|
||||
retval = 0;
|
||||
|
||||
mapblock = -1;
|
||||
mapblock_offset = -1;
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -94,24 +98,46 @@ ffs_mount (void)
|
||||
static int
|
||||
block_map (int file_block)
|
||||
{
|
||||
int bnum;
|
||||
int bnum, offset, bsize;
|
||||
|
||||
if (file_block < NDADDR)
|
||||
return (INODE->i_db[file_block]);
|
||||
|
||||
if ((bnum = fsbtodb (SUPERBLOCK, INODE->i_ib[0])) != mapblock)
|
||||
/* If the blockmap loaded does not include FILE_BLOCK,
|
||||
load a new blockmap. */
|
||||
if ((bnum = fsbtodb (SUPERBLOCK, INODE->i_ib[0])) != mapblock
|
||||
|| (mapblock_offset <= bnum && bnum <= mapblock_offset + mapblock_bsize))
|
||||
{
|
||||
if (!devread (bnum, 0, SUPERBLOCK->fs_bsize, (char *)MAPBUF))
|
||||
if (MAPBUF_LEN < SUPERBLOCK->fs_bsize)
|
||||
{
|
||||
offset = ((file_block - NDADDR) % NINDIR (SUPERBLOCK));
|
||||
bsize = MAPBUF_LEN;
|
||||
|
||||
if (offset + MAPBUF_LEN > SUPERBLOCK->fs_bsize)
|
||||
offset = (SUPERBLOCK->fs_bsize - MAPBUF_LEN) / sizeof (int);
|
||||
}
|
||||
else
|
||||
{
|
||||
bsize = SUPERBLOCK->fs_bsize;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
if (! devread (bnum, offset * sizeof (int), bsize, (char *) MAPBUF))
|
||||
{
|
||||
mapblock = -1;
|
||||
mapblock_bsize = -1;
|
||||
mapblock_offset = -1;
|
||||
errnum = ERR_FSYS_CORRUPT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
mapblock = bnum;
|
||||
mapblock_bsize = bsize;
|
||||
mapblock_offset = offset;
|
||||
}
|
||||
|
||||
return (((int *) MAPBUF)[(file_block - NDADDR) % NINDIR (SUPERBLOCK)]);
|
||||
return (((int *) MAPBUF)[((file_block - NDADDR) % NINDIR (SUPERBLOCK))
|
||||
- mapblock_offset]);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,13 +196,10 @@ loop:
|
||||
/* load current inode (defaults to the root inode) */
|
||||
|
||||
if (!devread (fsbtodb (SUPERBLOCK, itod (SUPERBLOCK, ino)),
|
||||
0, SUPERBLOCK->fs_bsize, (char *) FSYS_BUF))
|
||||
ino % (SUPERBLOCK->fs_inopb) * sizeof (struct dinode),
|
||||
sizeof (struct dinode), (char *) INODE))
|
||||
return 0; /* XXX what return value? */
|
||||
|
||||
memmove ((void *) INODE,
|
||||
(void *) &(((struct dinode *) FSYS_BUF)[ino % (SUPERBLOCK->fs_inopb)]),
|
||||
sizeof (struct dinode));
|
||||
|
||||
/* if we have a real file (and we're not just printing possibilities),
|
||||
then this is where we want to exit */
|
||||
|
||||
|
||||
Reference in new issue
Block a user