[parted-devel] [PATCH] dasd: avoid usage of uninitialized data
Brian C. Lane
bcl at redhat.com
Fri Mar 21 23:40:34 UTC 2014
On Thu, Mar 20, 2014 at 04:33:42PM +0100, Petr Uzel wrote:
> In ped_partition_new(), disk_specific data of PedPartition
> structure is allocated (via dasd_partition_new()). This
> data is later used uninitialized in dasd_partition_set_system().
>
> * libparted/labels/vtoc.c (dasd_partition_new):
> Zero out allocated disk_specific data.
> ---
> libparted/labels/dasd.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
> index a769866..f5b0f2b 100644
> --- a/libparted/labels/dasd.c
> +++ b/libparted/labels/dasd.c
> @@ -659,6 +659,8 @@ dasd_partition_new (const PedDisk* disk, PedPartitionType part_type,
> goto error;
>
> part->disk_specific = ped_malloc (sizeof (DasdPartitionData));
> + if (part->disk_specific)
> + memset(part->disk_specific, 0, sizeof(DasdPartitionData));
> return part;
Good idea, but you should just use ped_calloc instead.
--
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
More information about the parted-devel
mailing list