Commit 8cad3900 authored by Kai Lüke's avatar Kai Lüke

Fix NULL deref when no partition table is present

When creating a filesystem on a block device without
a partiton table, udisks_partition_table_get_type_
crashed because it was invoked with table as NULL.

However, this code should not even be executed if
no partition is to be added, so just move it into
the appropriate branch where it belongs to.

https://bugzilla.gnome.org/show_bug.cgi?id=794109
parent 474d116f
......@@ -346,27 +346,27 @@ finish_cb (GtkDialog *dialog, gint response_id, CreateFormatData *data) /* the a
return;
}
g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT);
if (g_strcmp0 (get_filesystem (data), "dos_extended") == 0)
{
partition_type = "0x05";
g_variant_builder_add (&options_builder, "{sv}", "partition-type", g_variant_new_string ("extended"));
}
else if (g_strcmp0 (udisks_partition_table_get_type_ (data->table), "dos") == 0)
if (data->add_partition)
{
if (gdu_utils_is_inside_dos_extended (data->client, data->table, data->add_partition_offset))
g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT);
if (g_strcmp0 (get_filesystem (data), "dos_extended") == 0)
{
g_variant_builder_add (&options_builder, "{sv}", "partition-type", g_variant_new_string ("logical"));
partition_type = "0x05";
g_variant_builder_add (&options_builder, "{sv}", "partition-type", g_variant_new_string ("extended"));
}
else
else if (g_strcmp0 (udisks_partition_table_get_type_ (data->table), "dos") == 0)
{
g_variant_builder_add (&options_builder, "{sv}", "partition-type", g_variant_new_string ("primary"));
if (gdu_utils_is_inside_dos_extended (data->client, data->table, data->add_partition_offset))
{
g_variant_builder_add (&options_builder, "{sv}", "partition-type", g_variant_new_string ("logical"));
}
else
{
g_variant_builder_add (&options_builder, "{sv}", "partition-type", g_variant_new_string ("primary"));
}
}
}
if (data->add_partition)
{
size = gdu_create_partition_page_get_size (data->partition_page);
udisks_partition_table_call_create_partition (data->table,
data->add_partition_offset,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment