From ba550773f30057b5053b3115a9e299e3d8cd0a7e Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Sat, 19 Mar 2011 11:55:59 +0000 Subject: Make amd64/i386 installboot error out if /boot would cross the BOOTBIOS_MAXSEC line. ok deraadt@. --- sys/arch/amd64/stand/installboot/installboot.c | 6 +++++- sys/arch/i386/stand/installboot/installboot.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'sys') diff --git a/sys/arch/amd64/stand/installboot/installboot.c b/sys/arch/amd64/stand/installboot/installboot.c index 837d2fc3cc7..1f89c270823 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.17 2011/03/17 12:53:44 krw Exp $ */ +/* $OpenBSD: installboot.c,v 1.18 2011/03/19 11:55:58 krw Exp $ */ /* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* @@ -240,6 +240,10 @@ write_bootblocks(int devfd, struct disklabel *dl) errx(1, "no OpenBSD partition"); } + if (start + (protosize / DEV_BSIZE) > BOOTBIOS_MAXSEC) + errx(1, "invalid location: all of /boot must be < sector %u.", + BOOTBIOS_MAXSEC); + if (verbose) fprintf(stderr, "/boot will be written at sector %u\n", start); diff --git a/sys/arch/i386/stand/installboot/installboot.c b/sys/arch/i386/stand/installboot/installboot.c index edc4aa6626d..85fdb19948b 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.60 2011/03/17 12:53:44 krw Exp $ */ +/* $OpenBSD: installboot.c,v 1.61 2011/03/19 11:55:58 krw Exp $ */ /* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* @@ -236,6 +236,10 @@ write_bootblocks(int devfd, struct disklabel *dl) errx(1, "no OpenBSD partition"); } + if (start + (protosize / DEV_BSIZE) > BOOTBIOS_MAXSEC) + errx(1, "invalid location: all of /boot must be < sector %u.", + BOOTBIOS_MAXSEC); + if (verbose) fprintf(stderr, "/boot will be written at sector %u\n", start); -- cgit v1.2.3