[libvirt] [PATCH] bridge: Fix potential segfault when preparing dnsmasq arguments

We add --dhcp-lease-max=xxx argument when network->def->nranges > 0 but we only allocate space for in the opposite case :-) I guess we are lucky enough to miscount somewhere else so that we actually allocate more space than we need since no-one has hit this bug so far. --- src/network/bridge_driver.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 59e02b1..f247a0f 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -426,7 +426,7 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network, 2 + /* --listen-address 10.0.0.1 */ (2 * network->def->nranges) + /* --dhcp-range 10.0.0.2,10.0.0.254 */ /* --dhcp-lease-max=xxx if needed */ - (network->def->nranges ? 0 : 1) + + (network->def->nranges ? 1 : 0) + /* --dhcp-hostsfile=/var/lib/dnsmasq/$NAME.hostsfile */ (network->def->nhosts > 0 ? 1 : 0) + /* --enable-tftp --tftp-root /srv/tftp */ -- 1.7.2

On 08/11/2010 10:44 AM, Jiri Denemark wrote:
We add --dhcp-lease-max=xxx argument when network->def->nranges > 0 but we only allocate space for in the opposite case :-) I guess we are lucky enough to miscount somewhere else so that we actually allocate more space than we need since no-one has hit this bug so far.
ACK. Boy will it be nice to move to the newer exec wrappers that eliminates the need for each client to malloc the right size argv themselves. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

We add --dhcp-lease-max=xxx argument when network->def->nranges > 0 but we only allocate space for in the opposite case :-) I guess we are lucky enough to miscount somewhere else so that we actually allocate more space than we need since no-one has hit this bug so far.
ACK. Boy will it be nice to move to the newer exec wrappers that eliminates the need for each client to malloc the right size argv themselves.
Yeah, I'm really looking forward to that. Pushed. Jirka
participants (2)
-
Eric Blake
-
Jiri Denemark