Re: [PATCH ima-evm-utils] evmctl: fix memory leak in get_password

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 11, 2021 at 01:31:49PM -0400, Mimi Zohar wrote:
> On Wed, 2021-08-11 at 13:51 -0300, Bruno Meneguele wrote:
> > On Wed, Aug 11, 2021 at 10:52:00AM -0400, Mimi Zohar wrote:
> > 
> > > > 
> > > > -	return pwd;
> > > > +	return password;
> > > 
> > > Wouldn't a simpler fix be to test "pwd" here?
> > >         if (!pwd)
> > >                 free(password);
> > >         return pwd;
> > > 
> > 
> > The problem is on success, when 'pwd' is actually not NULL.
> > With that, I can't free(password). I would need to asprintf(pwd, ...) or
> > strndup(password). Because of that, I thought it would be cleaner to
> > remove 'password' completely.
> 
> I see.  So instead of "return pwd" as suggested above,
> 
>         if (!pwd) {
>                 free(password);
>                 password = NULL;  <== set or return NULL
>         }
> 
>         return password;
> 

Ack. Will send a v2 with this change.

Thanks Mimi.

-- 
bmeneg 
PGP Key: http://bmeneg.com/pubkey.txt

Attachment: signature.asc
Description: PGP signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux