Re: [PATCH] Allow relative path for qemu backing file

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

 



On 04/05/2011 10:55 AM, Jesse J Cook wrote:
>>> +        if ('/' != *(vol->backingStore.path)) {
>>> +            virAsprintf(&absolutePath, "%s/%s", pool->def->target.path,
>>> +                        vol->backingStore.path);
>>> +
>>> +        } else {
>>> +            virAsprintf(&absolutePath, "%s", vol->backingStore.path);
>>
>> strdup is more efficient here, and avoiding malloc in the first place
>> even more so.
>>
>>> +        }
>>> +        accessRetCode = access(absolutePath, R_OK);
>>
>> This could segfault on OOM.
>>
>>> +        VIR_FREE(absolutePath);
> 
> I believe there needs to be a NULL check here or absolute paths and
> virAsprintf errors will segfault. I can patch if you don't beat me to
> it.

How so?  absolutePath was initialized as NULL; is only ever set to
non-null by a successful virAsprintf, and VIR_FREE works correctly
(no-op) on a NULL argument.  Put another way, are you missing that
VIR_FREE already has an embedded NULL check?

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]