Another one I sent to bugs@ a while ago.

I'm assuming that having 'i386' in the original subject line made everyone hit 
their 'd' key, without realizing that this affects amd64 too...

The patch below fixes an off-by-one in /arch/amd64/stand/libsa/cmd_i386.c.

The affected code path is handling the machine boot command in the bootloader. 
Currently, trying to boot from MBR partition 'a', with a command such as 
machine boot hd0a, will in fact boot from whichever partition is flagged as 
active, rather than forcing a boot from partition 'a'.

The bug was introduced in revision 1.20 of the original i386 architecture file 
over 20 years ago on 19980224.

untrusted comment: verify with signify key for exoticsilicon.com
RWRn5d3Yx35u0w51USyxAkjCzjLo99UNE67gXzvuaTGbD9cMlTKdDTOAOe7JA6LV/VLWqmomwo7D9m399vKnra2KyrUn/EYcUgo=
--- arch/amd64/stand/libsa/cmd_i386.c.dist      Fri May 10 18:20:43 2019
+++ arch/amd64/stand/libsa/cmd_i386.c   Sun Aug 15 23:44:45 2021
@@ -107,7 +107,7 @@
        dev += (cmd.argv[1][2] - '0');
        part = (cmd.argv[1][3] - 'a');
 
-       if (part > 0)
+       if (part >= 0)
                printf("[%x,%d]\n", dev, part);
        else
                printf("[%x]\n", dev);
@@ -119,7 +119,7 @@
                goto bad;
 
        /* Frob boot flag in buffer from HD */
-       if ((dev & 0x80) && (part > 0)){
+       if ((dev & 0x80) && (part >= 0)){
                int i, j;
 
                for (i = 0, j = DOSPARTOFF; i < 4; i++, j += 16)
--- arch/i386/stand/libsa/cmd_i386.c.dist       Fri Jun 10 15:36:06 2016
+++ arch/i386/stand/libsa/cmd_i386.c    Sun Aug 15 23:44:23 2021
@@ -119,7 +119,7 @@
        dev += (cmd.argv[1][2] - '0');
        part = (cmd.argv[1][3] - 'a');
 
-       if (part > 0)
+       if (part >= 0)
                printf("[%x,%d]\n", dev, part);
        else
                printf("[%x]\n", dev);
@@ -131,7 +131,7 @@
                goto bad;
 
        /* Frob boot flag in buffer from HD */
-       if ((dev & 0x80) && (part > 0)){
+       if ((dev & 0x80) && (part >= 0)){
                int i, j;
 
                for (i = 0, j = DOSPARTOFF; i < 4; i++, j += 16)

Reply via email to