[parted-devel] [PATCH 4/8] libparted: check return value from ped_geometry_init
Jim Meyering
jim at meyering.net
Sat Oct 1 07:27:56 UTC 2011
Petr Uzel wrote:
> If ped_geometry_init() failed in ped_disk_set_partition_geom(),
> then new_geom remains uninitialized, but still later used, which
> leads to unexpected results.
>
> * libparted/disk.c (ped_disk_set_partition_geom): Check return
> value from ped_geometry_init().
>
> Signed-off-by: Petr Uzel <petr.uzel at suse.cz>
> ---
> libparted/disk.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/libparted/disk.c b/libparted/disk.c
> index 1057aa8..807b53a 100644
> --- a/libparted/disk.c
> +++ b/libparted/disk.c
> @@ -2171,7 +2171,8 @@ ped_disk_set_partition_geom (PedDisk* disk, PedPartition* part,
> PED_ASSERT (part->disk == disk);
>
> old_geom = part->geom;
> - ped_geometry_init (&new_geom, part->geom.dev, start, end - start + 1);
> + if (!ped_geometry_init (&new_geom, part->geom.dev, start, end - start + 1))
> + return 0;
Obviously a good change. Applied.
More information about the parted-devel
mailing list