]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: fix segfault on bsd label
authorDavidlohr Bueso <dave@gnu.org>
Fri, 4 May 2012 11:35:32 +0000 (13:35 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 10 May 2012 09:32:04 +0000 (11:32 +0200)
Commit 8db8295d824cd0c8cba9385e4635d6e311d69d3f added a regression that causes the program to crash when
touching the partition structure (pte) for BSD/OSF labels. Since DOS has its own initialization function,
allow BSD labels to use it as well.

Steps to reproduce:

$> fdisk bsd.img (obtained from blkid regression test files)
Command (m for help): p
...
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Segmentation fault

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
fdisk/fdisk.c
fdisk/fdiskdoslabel.c
fdisk/fdiskdoslabel.h

index acc84d1c845fe135d6b54fbdc27a459a0c783a48..dccaf27fdae74ff373613d7d45e3612342e8562f 100644 (file)
@@ -763,6 +763,8 @@ static int get_boot(int try_only) {
                        return 0;
 
        if (check_osf_label()) {
+               /* intialize partitions for BSD as well */
+               dos_init();
                if (!valid_part_table_flag(MBRbuffer)) {
                        disklabel = OSF_LABEL;
                        return 0;
index c6e4198dd1dd139f03e78c3ebd4dd3661ab5c330..4dfe876dcc757833ed7ba1297a04aa8438507b3c 100644 (file)
@@ -54,7 +54,7 @@ static void clear_partition(struct partition *p)
        set_nr_sects(p,0);
 }
 
-static void dos_init(void)
+void dos_init(void)
 {
        int i;
 
index f5568dff28540d2b3dd617e11d24e48230179ee0..1897b6c88b716b2016c5ab3c035122c577178c86 100644 (file)
@@ -48,5 +48,6 @@ extern void dos_set_mbr_id(void);
 extern void dos_delete_partition(int i);
 extern int check_dos_label(void);
 extern int is_dos_partition(int t);
+extern void dos_init(void);
 
 #endif