]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - parted/patches/parted-2.1-mem-leak-fixes-rh556012.patch
Change file layout of the makefiles.
[people/ms/ipfire-3.x.git] / parted / patches / parted-2.1-mem-leak-fixes-rh556012.patch
1 From 358c9846a014247605d8da47b6917cac1344de00 Mon Sep 17 00:00:00 2001
2 From: Jim Meyering <meyering@redhat.com>
3 Date: Fri, 15 Jan 2010 20:14:38 +0100
4 Subject: [PATCH] dos: don't leak a constraint upon partition-add failure
5
6 * libparted/labels/dos.c (read_table): Free constraint upon failure.
7 ---
8 libparted/labels/dos.c | 9 +++++----
9 1 files changed, 5 insertions(+), 4 deletions(-)
10
11 diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
12 index 6b8d6cb..339acf4 100644
13 --- a/libparted/labels/dos.c
14 +++ b/libparted/labels/dos.c
15 @@ -873,7 +873,6 @@ read_table (PedDisk* disk, PedSector sector, int is_extended_table)
16 PedPartition* part;
17 PedPartitionType type;
18 PedSector lba_offset;
19 - PedConstraint* constraint_exact;
20
21 PED_ASSERT (disk != NULL, return 0);
22 PED_ASSERT (disk->dev != NULL, return 0);
23 @@ -944,10 +943,12 @@ read_table (PedDisk* disk, PedSector sector, int is_extended_table)
24 if (type != PED_PARTITION_EXTENDED)
25 part->fs_type = ped_file_system_probe (&part->geom);
26
27 - constraint_exact = ped_constraint_exact (&part->geom);
28 - if (!ped_disk_add_partition (disk, part, constraint_exact))
29 - goto error;
30 + PedConstraint *constraint_exact
31 + = ped_constraint_exact (&part->geom);
32 + bool ok = ped_disk_add_partition (disk, part, constraint_exact);
33 ped_constraint_destroy (constraint_exact);
34 + if (!ok)
35 + goto error;
36
37 /* non-nested extended partition */
38 if (part->type == PED_PARTITION_EXTENDED) {
39 --
40 1.6.3.3
41
42 From d0cec198183be0b9989e4bc729c2930c7cdfe545 Mon Sep 17 00:00:00 2001
43 From: Jim Meyering <meyering@redhat.com>
44 Date: Fri, 15 Jan 2010 19:53:36 +0100
45 Subject: [PATCH] gpt: don't leak a constraint upon partition-add failure
46
47 * libparted/labels/gpt.c (gpt_read): Free constraint upon failure.
48 ---
49 libparted/labels/gpt.c | 4 ++--
50 1 files changed, 2 insertions(+), 2 deletions(-)
51
52 diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
53 index 76537fd..9d9876c 100644
54 --- a/libparted/labels/gpt.c
55 +++ b/libparted/labels/gpt.c
56 @@ -1020,7 +1020,6 @@ gpt_read (PedDisk *disk)
57 GuidPartitionEntry_t *pte
58 = (GuidPartitionEntry_t *) ((char *) ptes + i * p_ent_size);
59 PedPartition *part;
60 - PedConstraint *constraint_exact;
61
62 if (!guid_cmp (pte->PartitionTypeGuid, UNUSED_ENTRY_GUID))
63 continue;
64 @@ -1032,9 +1031,10 @@ gpt_read (PedDisk *disk)
65 part->fs_type = ped_file_system_probe (&part->geom);
66 part->num = i + 1;
67
68 - constraint_exact = ped_constraint_exact (&part->geom);
69 + PedConstraint *constraint_exact = ped_constraint_exact (&part->geom);
70 if (!ped_disk_add_partition (disk, part, constraint_exact))
71 {
72 + ped_constraint_destroy (constraint_exact);
73 ped_partition_destroy (part);
74 goto error_delete_all;
75 }
76 --
77 1.6.3.3
78
79 From 952e4919befce199b096fd1bbde93ef7902239d3 Mon Sep 17 00:00:00 2001
80 From: Jim Meyering <meyering@redhat.com>
81 Date: Fri, 15 Jan 2010 19:34:00 +0100
82 Subject: [PATCH] gpt: do not leak a GPT header on an error path
83
84 * libparted/labels/gpt.c (gpt_write): Avoid a leak by freeing the
85 header buffer after pth_get_raw call where it's used, but before
86 checking whether that pth_get_raw call succeeded.
87 Avoid another leak in identical just 10 lines down.
88 Add "FIXME: caution..." comments to warn about the duplication.
89 ---
90 libparted/labels/gpt.c | 12 ++++++++----
91 1 files changed, 8 insertions(+), 4 deletions(-)
92
93 diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
94 index fe1f300..76537fd 100644
95 --- a/libparted/labels/gpt.c
96 +++ b/libparted/labels/gpt.c
97 @@ -1208,11 +1208,13 @@ gpt_write (const PedDisk *disk)
98 goto error_free_ptes;
99
100 /* Write PTH and PTEs */
101 + /* FIXME: Caution: this code is nearly identical to what's just below. */
102 if (_generate_header (disk, 0, ptes_crc, &gpt) != 0)
103 goto error_free_ptes;
104 - if ((pth_raw = pth_get_raw (disk->dev, gpt)) == NULL)
105 - goto error_free_ptes;
106 + pth_raw = pth_get_raw (disk->dev, gpt);
107 pth_free (gpt);
108 + if (pth_raw == NULL)
109 + goto error_free_ptes;
110 int write_ok = ped_device_write (disk->dev, pth_raw, 1, 1);
111 free (pth_raw);
112 if (!write_ok)
113 @@ -1222,11 +1224,13 @@ gpt_write (const PedDisk *disk)
114 goto error_free_ptes;
115
116 /* Write Alternate PTH & PTEs */
117 + /* FIXME: Caution: this code is nearly identical to what's just above. */
118 if (_generate_header (disk, 1, ptes_crc, &gpt) != 0)
119 goto error_free_ptes;
120 - if ((pth_raw = pth_get_raw (disk->dev, gpt)) == NULL)
121 - goto error_free_ptes;
122 + pth_raw = pth_get_raw (disk->dev, gpt);
123 pth_free (gpt);
124 + if (pth_raw == NULL)
125 + goto error_free_ptes;
126 write_ok = ped_device_write (disk->dev, pth_raw, disk->dev->length - 1, 1);
127 free (pth_raw);
128 if (!write_ok)
129 --
130 1.6.3.3
131
132 From 19b072592a7a551a861c200be58aef04a7546fb9 Mon Sep 17 00:00:00 2001
133 From: Jim Meyering <meyering@redhat.com>
134 Date: Fri, 15 Jan 2010 18:56:37 +0100
135 Subject: [PATCH] libparted: avoid double-free on an OOM failure path
136
137 * libparted/disk.c (ped_disk_check): Don't double-free "fs_size".
138 ---
139 libparted/disk.c | 2 ++
140 1 files changed, 2 insertions(+), 0 deletions(-)
141
142 diff --git a/libparted/disk.c b/libparted/disk.c
143 index c14d005..2d27b7c 100644
144 --- a/libparted/disk.c
145 +++ b/libparted/disk.c
146 @@ -632,7 +632,9 @@ ped_disk_check (const PedDisk* disk)
147 walk->num, part_size, fs_size);
148
149 free (part_size);
150 +
151 free (fs_size);
152 + fs_size = NULL;
153
154 if (choice != PED_EXCEPTION_IGNORE)
155 return 0;
156 --
157 1.6.3.3
158