Module Name: src Committed By: perseant Date: Wed Jun 13 18:34:20 UTC 2012
Modified Files: src/sys/arch/i386/stand/lib: biosdisk.c Log Message: Sanity check the values coming back from the int13 extensions of the bios, so we can catch impossible return values. Allows the bootloader to work again on the Soekris net4501. Fixes PR kern/46027. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/arch/i386/stand/lib/biosdisk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/i386/stand/lib/biosdisk.c diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.40 src/sys/arch/i386/stand/lib/biosdisk.c:1.41 --- src/sys/arch/i386/stand/lib/biosdisk.c:1.40 Mon Jan 16 18:47:57 2012 +++ src/sys/arch/i386/stand/lib/biosdisk.c Wed Jun 13 18:34:20 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: biosdisk.c,v 1.40 2012/01/16 18:47:57 christos Exp $ */ +/* $NetBSD: biosdisk.c,v 1.41 2012/06/13 18:34:20 perseant Exp $ */ /* * Copyright (c) 1996, 1998 @@ -316,7 +316,9 @@ read_gpt(struct biosdisk *d) gptsector[0] = GPT_HDR_BLKNO; if (set_geometry(&d->ll, &ed) == 0 && d->ll.flags & BIOSDISK_INT13EXT) { gptsector[1] = ed.totsec - 1; - d->ll.secsize = ed.sbytes; + /* Sanity check values returned from BIOS */ + if (ed.sbytes >= 512 && (ed.sbytes & (ed.sbytes - 1)) == 0) + d->ll.secsize = ed.sbytes; } else { #ifdef DISK_DEBUG printf("Unable to determine extended disk geometry - "