diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-11-13 04:11:35 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-11-13 04:11:35 +0000 |
commit | a7e033c6597a98664888717d727b131f7668f53e (patch) | |
tree | fd98ba6bf56f9a3f1c8a2cf03195314048984fab /sys/arch/amd64/stand/installboot/installboot.c | |
parent | 7f0710e511904b31216967a3e9631aa0c72520c8 (diff) |
Use DL_GETPOFFSET() to get partition offset, except where we
explicitly check p_offseth before assigning p_offset to
local variables. Add missing check for p_offseth.
Diffstat (limited to 'sys/arch/amd64/stand/installboot/installboot.c')
-rw-r--r-- | sys/arch/amd64/stand/installboot/installboot.c | 13 |
1 files changed, 7 insertions, 6 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)); } |