bug-parted
[Top][All Lists]
Advanced

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

[PATCH] fix msdos_partition_set_system segfault


From: Andreas Dilger
Subject: [PATCH] fix msdos_partition_set_system segfault
Date: Thu, 31 Jan 2002 17:29:56 -0700
User-agent: Mutt/1.2.5.1i

The following patch fixes msdos_partition_set_system() so that it will not
segfault if a NULL fs_type is passed in.  It would _appear_ that this is
handled in some cases, and is also handled in other set_system() methods,
but maybe some changes were added on withouth thinking about this case.

An independent patch (which brings this problem out) is also included,
but probably isn't what you want in the real product.  It allows you
to continue in the case where filesystem support is disabled and there
is an empty list for the filesystem type (otherwise it is not possible
to create a partition at all).

In theory, you should still be able to specify "fat32" as the filesystem
type and get all of the corresponding magic for msdos partition types,
but that is currently impossible.  You could do this by passing a new
fs_type with NULL ->ops into these routines, just so you get the ->name
field down there, but that might blow up later (I don't know).

Cheers, Andreas
================= parted-1.6.0-fs_type.diff ==============================
--- libparted/disk_dos.c.orig   Thu Jan 24 05:53:06 2002
+++ libparted/disk_dos.c        Thu Jan 31 17:01:20 2002
@@ -936,14 +940,9 @@
 
        if (part->geom.end >= cyl_size * 1024
            && (part->type & PED_PARTITION_EXTENDED
-                       || strncmp (fs_type->name, "fat", 3)))
+                       || (fs_type && strncmp (fs_type->name, "fat", 3))))
                dos_data->lba = 1;
 
-       if (dos_data->hidden
-                   && strncmp (fs_type->name, "fat", 3) != 0
-                   && strcmp (fs_type->name, "ntfs") != 0)
-               dos_data->hidden = 0;
-
        if (part->type & PED_PARTITION_EXTENDED) {
                dos_data->raid = 0;
                dos_data->lvm = 0;
@@ -963,9 +962,10 @@
                return 1;
        }
 
-       if (!fs_type)
+       if (!fs_type) {
                dos_data->system = 0x83;
-       else if (!strcmp (fs_type->name, "fat16")) {
+               dos_data->hidden = 0;
+       } else if (!strcmp (fs_type->name, "fat16")) {
                if (dos_data->hidden)
                        dos_data->system = dos_data->lba ? 0x1e : 0x16;
                else
@@ -980,10 +980,13 @@
                        dos_data->system = 0x17;
                else
                        dos_data->system = 0x7;
-       } else if (!strcmp (fs_type->name, "linux-swap"))
+       } else if (!strcmp (fs_type->name, "linux-swap")) {
                dos_data->system = 0x82;
-       else
+               dos_data->hidden = 0;
+       } else {
                dos_data->system = 0x83;
+               dos_data->hidden = 0;
+       }
 
        return 1;
 }
--- parted/parted.c.orig        Sat Jan 26 09:13:01 2002
+++ parted/parted.c     Thu Jan 31 17:17:50 2002
@@ -546,7 +546,7 @@
                fs_type = command_line_get_fs_type (_("File system type?"),
                                                    def_type);
                if (!fs_type)
-                       goto error_destroy_constraint;
+                       printf("unknown fs type, using defaults\n");
        }
 
        if (!command_line_get_sector (_("Start?"), *dev, 0, &start))
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]