diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/stand/installboot/installboot.c | 13 | ||||
-rw-r--r-- | sys/arch/i386/stand/installboot/installboot.c | 13 |
2 files changed, 14 insertions, 12 deletions
diff --git a/sys/arch/amd64/stand/installboot/installboot.c b/sys/arch/amd64/stand/installboot/installboot.c index fdd08bea95f..30ea0c80bb9 100644 --- a/sys/arch/amd64/stand/installboot/installboot.c +++ b/sys/arch/amd64/stand/installboot/installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: installboot.c,v 1.26 2013/06/11 16:42:07 deraadt Exp $ */ +/* $OpenBSD: installboot.c,v 1.27 2013/11/13 04:11:34 krw Exp $ */ /* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* @@ -489,7 +489,7 @@ getbootparams(char *boot, int devfd, struct disklabel *dl) close(fd); /* Read superblock. */ - devread(devfd, sblock, DL_SECTOBLK(dl, pp->p_offset) + SBLOCK, + devread(devfd, sblock, DL_SECTOBLK(dl, DL_GETPOFFSET(pp)) + SBLOCK, SBSIZE, "superblock"); fs = (struct fs *)sblock; @@ -505,7 +505,7 @@ getbootparams(char *boot, int devfd, struct disklabel *dl) blk = fsbtodb(fs, ino_to_fsba(fs, statbuf.st_ino)); - devread(devfd, buf, DL_SECTOBLK(dl, pp->p_offset) + blk, + devread(devfd, buf, DL_SECTOBLK(dl, DL_GETPOFFSET(pp)) + blk, fs->fs_bsize, "inode"); ip = (struct ufs1_dinode *)(buf) + ino_to_fsbo(fs, statbuf.st_ino); @@ -537,6 +537,8 @@ getbootparams(char *boot, int devfd, struct disklabel *dl) sym_set_value(pbr_symbols, "_fsbtodb", ffs(fs->fs_fsize / dl->d_secsize) - 1); + if (pp->p_offseth != 0) + errx(1, "partition offset too high"); sym_set_value(pbr_symbols, "_p_offset", pp->p_offset); sym_set_value(pbr_symbols, "_inodeblk", ino_to_fsba(fs, statbuf.st_ino)); @@ -548,11 +550,10 @@ getbootparams(char *boot, int devfd, struct disklabel *dl) if (verbose) { fprintf(stderr, "%s is %d blocks x %d bytes\n", boot, ndb, fs->fs_bsize); - fprintf(stderr, "fs block shift %u; part offset %u; " + fprintf(stderr, "fs block shift %u; part offset %llu; " "inode block %lld, offset %u\n", ffs(fs->fs_fsize / dl->d_secsize) - 1, - pp->p_offset, - ino_to_fsba(fs, statbuf.st_ino), + DL_GETPOFFSET(pp), ino_to_fsba(fs, statbuf.st_ino), (unsigned int)((((char *)ap) - buf) + INODEOFF)); } diff --git a/sys/arch/i386/stand/installboot/installboot.c b/sys/arch/i386/stand/installboot/installboot.c index 00dd0dd54bf..42dcb3dd1b3 100644 --- a/sys/arch/i386/stand/installboot/installboot.c +++ b/sys/arch/i386/stand/installboot/installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: installboot.c,v 1.69 2013/06/11 16:42:08 deraadt Exp $ */ +/* $OpenBSD: installboot.c,v 1.70 2013/11/13 04:11:34 krw Exp $ */ /* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* @@ -485,7 +485,7 @@ getbootparams(char *boot, int devfd, struct disklabel *dl) close(fd); /* Read superblock. */ - devread(devfd, sblock, DL_SECTOBLK(dl, pp->p_offset) + SBLOCK, + devread(devfd, sblock, DL_SECTOBLK(dl, DL_GETPOFFSET(pp)) + SBLOCK, SBSIZE, "superblock"); fs = (struct fs *)sblock; @@ -501,7 +501,7 @@ getbootparams(char *boot, int devfd, struct disklabel *dl) blk = fsbtodb(fs, ino_to_fsba(fs, statbuf.st_ino)); - devread(devfd, buf, DL_SECTOBLK(dl, pp->p_offset) + blk, + devread(devfd, buf, DL_SECTOBLK(dl, DL_GETPOFFSET(pp)) + blk, fs->fs_bsize, "inode"); ip = (struct ufs1_dinode *)(buf) + ino_to_fsbo(fs, statbuf.st_ino); @@ -533,6 +533,8 @@ getbootparams(char *boot, int devfd, struct disklabel *dl) sym_set_value(pbr_symbols, "_fsbtodb", ffs(fs->fs_fsize / dl->d_secsize) - 1); + if (pp->p_offseth != 0) + errx(1, "partition offset too high"); sym_set_value(pbr_symbols, "_p_offset", pp->p_offset); sym_set_value(pbr_symbols, "_inodeblk", ino_to_fsba(fs, statbuf.st_ino)); @@ -544,11 +546,10 @@ getbootparams(char *boot, int devfd, struct disklabel *dl) if (verbose) { fprintf(stderr, "%s is %d blocks x %d bytes\n", boot, ndb, fs->fs_bsize); - fprintf(stderr, "fs block shift %u; part offset %u; " + fprintf(stderr, "fs block shift %u; part offset %llu; " "inode block %lld, offset %u\n", ffs(fs->fs_fsize / dl->d_secsize) - 1, - pp->p_offset, - ino_to_fsba(fs, statbuf.st_ino), + DL_GETPOFFSET(pp), ino_to_fsba(fs, statbuf.st_ino), (unsigned int)((((char *)ap) - buf) + INODEOFF)); } |