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

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

 



On Tue, 2011-04-05 at 11:00 -0600, Eric Blake wrote:
> 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.

Disregard. The code is correct.

> 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?
> 

Thank you for resolving my fundamental misunderstanding regarding the
behaviour of free(3). I did not realize free((void*)0) is safe.

-- 
Jesse Cook
Research Scientist
EADS NA Defense Security & Systems Solutions, Inc. (DS3)
1476 N. Green Mount Rd
O'Fallon, Illinois 62269
Office: 618.206.4032 x436
Email: jesse.cook@xxxxxxxxxxxxxxxxxxxx
http://www.eads-na-security.com

--
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]