]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Fix misc bugs in virCommandPtr
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 8 Mar 2011 18:06:09 +0000 (18:06 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 15 Mar 2011 15:26:35 +0000 (15:26 +0000)
commit2a2a00eb692b931bf60f388d12f767543fed1214
tree6ed8307a5ec21af9de4d9d851157b381cc659038
parent2737b6c20bb18906aa72ecb1eeb10303943b72fc
Fix misc bugs in virCommandPtr

The virCommandNewArgs() method would free the virCommandPtr
if it failed to add the args. This meant errors reported in
virCommandAddArgSet() were lost. Simply removing the check
for errors from the constructor means they can be reported
correctly later

The virCommandAddEnvPassCommon() method failed to check for
errors before reallocating the cmd->env array, causing a
potential SEGV if cmd was NULL

The virCommandAddArgSet() method needs to validate that at
least 1 element in 'val's parameter is non-NULL, otherwise
code like

    cmd = virCommandNew(binary)
    virCommandAddAtg(cmd, "foo")

Would end up trying todo  execve("foo"), if binary was
NULL.
src/util/command.c