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

Re: [libvirt] PATCH: Fix NULL checks in openvz driver



On Mon, Sep 08, 2008 at 04:06:26PM +0400, Evgeniy Sokolov wrote:
> >On Fri, Sep 05, 2008 at 05:40:16PM +0200, Jim Meyering wrote:
> >>"Daniel P. Berrange" <berrange redhat com> wrote:
> >>>Jim pointed out some places where the openvz driver could deference some
> >>>NULs, so this patch fixes them
> >>...
> >>>Index: src/openvz_driver.c
> >>>===================================================================
> >>>RCS file: /data/cvs/libvirt/src/openvz_driver.c,v
> >>>retrieving revision 1.46
> >>>diff -u -p -r1.46 openvz_driver.c
> >>>--- src/openvz_driver.c	5 Sep 2008 15:00:14 -0000	1.46
> >>>+++ src/openvz_driver.c	5 Sep 2008 15:11:34 -0000
> >>>@@ -276,7 +276,7 @@ static char *openvzDomainDumpXML(virDoma
> >>> static int openvzDomainShutdown(virDomainPtr dom) {
> >>>     struct openvz_driver *driver = (struct openvz_driver 
> >>>     *)dom->conn->privateData;
> >>>     virDomainObjPtr vm = virDomainFindByUUID(driver->domains, 
> >>>     dom->uuid);
> >>>-    const char *prog[] = {VZCTL, "--quiet", "stop", vm->def->name, 
> >>>NULL};
> >>>+    const char *prog[] = {VZCTL, "--quiet", "stop", NULL /* name */, 
> >>>NULL};
> >>...
> >>>+    prog[3] = vm->def->name;
> >>>     if (virRun(dom->conn, prog, NULL) < 0)
> >>>         return -1;
> >>>
> >>...
> >>
> >>All looks correct.
> >>However, I'm a little nervous about hard-coding those '[3]'s.
> >>What if someone inserts a new --foo option somewhere before
> >>the NULL place-holder, or otherwise rearranges the options?
> >>Then we'll have to remember to update that "3" below to e.g., "4".
> >>Easy to miss that...
> >
> >I just realized there is a much simpler way todo this...

[snip]

> It looks very good.

Thanks, this is committed now


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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