[parted-devel] [PATCH] dasd: avoid usage of uninitialized data

Petr Uzel petr.uzel at suse.cz
Thu Mar 27 07:32:44 UTC 2014


On Fri, Mar 21, 2014 at 04:40:34PM -0700, Brian C. Lane wrote:
> 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.

Heh, of course - I have no idea why I did not use it right away :/

Updated version sent to mailing list.

Thanks,


        Petr

-- 
Petr Uzel
TL SUSE L3 Team 2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20140327/6d67524e/attachment.sig>


More information about the parted-devel mailing list