Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/stand/lib Sanity check the values coming back ...



details:   https://anonhg.NetBSD.org/src/rev/807334e35282
branches:  trunk
changeset: 779716:807334e35282
user:      perseant <perseant%NetBSD.org@localhost>
date:      Wed Jun 13 18:34:20 2012 +0000

description:
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.

diffstat:

 sys/arch/i386/stand/lib/biosdisk.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (20 lines):

diff -r 99f2ffcc7435 -r 807334e35282 sys/arch/i386/stand/lib/biosdisk.c
--- a/sys/arch/i386/stand/lib/biosdisk.c        Wed Jun 13 17:13:41 2012 +0000
+++ b/sys/arch/i386/stand/lib/biosdisk.c        Wed Jun 13 18:34:20 2012 +0000
@@ -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 @@
        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 - "



Home | Main Index | Thread Index | Old Index