Re: [PATCH 2/2] nfs-utils: mount.nfs: fix null pointer derefernce in nfs_parse_simple_hostname

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

 



thanks for review!
actually, it fixed a coverity issue a while back, so I thought of
sharing this minor change.

thanks!

On Wed, Dec 2, 2015 at 9:46 PM, Steve Dickson <SteveD@xxxxxxxxxx> wrote:
> hello,
>
> On 12/02/2015 06:16 AM, Vivek Trivedi wrote:
>> In function nfs_parse_simple_hostname, hostname can be NULL,
>> dereferncing it while passing it to free(*hostname) may result in segfault.
> Again I can see the logic but I wondering why/how a NULL hostname
> is being passed. I don't see how a NULL hostname can be passed
> in esp during a mount....
>
> steved.
>
>>
>> Signed-off-by: Vivek Trivedi <t.vivek@xxxxxxxxxxx>
>> ---
>>  utils/mount/parse_dev.c |    3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/utils/mount/parse_dev.c b/utils/mount/parse_dev.c
>> index d64b83d..0d3bcb9 100644
>> --- a/utils/mount/parse_dev.c
>> +++ b/utils/mount/parse_dev.c
>> @@ -118,7 +118,8 @@ static int nfs_parse_simple_hostname(const char *dev,
>>       if (pathname) {
>>               *pathname = strndup(colon, path_len);
>>               if (*pathname == NULL) {
>> -                     free(*hostname);
>> +                     if (hostname)
>> +                             free(*hostname);
>>                       return nfs_pdn_nomem_err();
>>               }
>>       }
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux