[gnome-disk-utility] Fix NULL deref when no partition table is present
- From: Kai Lüke <kailueke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Fix NULL deref when no partition table is present
- Date: Mon, 12 Mar 2018 12:28:04 +0000 (UTC)
commit 8cad3900adad91222eb87d5c903ecd0aded8fcdb
Author: Kai Lüke <kailueke riseup net>
Date: Tue Mar 6 20:38:38 2018 +0900
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
src/disks/gducreateformatdialog.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/src/disks/gducreateformatdialog.c b/src/disks/gducreateformatdialog.c
index 8616c75..e09d4cf 100644
--- a/src/disks/gducreateformatdialog.c
+++ b/src/disks/gducreateformatdialog.c
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]