mbr: make alignment/padding safe
authorAlan Cox <alan@linux.intel.com>
Tue, 13 Sep 2016 10:59:20 +0000 (11:59 +0100)
committerAlan Cox <alan@linux.intel.com>
Tue, 13 Sep 2016 10:59:20 +0000 (11:59 +0100)
Kernel/dev/mbr.c

index f914ec2..8c4006c 100644 (file)
@@ -7,10 +7,9 @@
 #include <config.h>
 
 typedef struct {
-    uint8_t  status;
-    uint8_t  chs_first[3];
-    uint8_t  type;
-    uint8_t  chs_last[3];
+    /* Described this way so that it packs */
+    uint8_t  status_chs_first[4];
+    uint8_t  type_chs_last[4];
     uint32_t lba_first;
     uint32_t lba_count;
 } partition_table_entry_t;
@@ -70,7 +69,7 @@ void mbr_parse(char letter)
         blk_op.lba = 0;
 
        for(i=0; i<MBR_ENTRY_COUNT && next < MAX_PARTITIONS; i++){
-           switch(br->partition[i].type){
+           switch(br->partition[i].type_chs_last[0]){
                case 0:
                    break;
                case 0x05: