]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bridge: Fix potential segfault when preparing dnsmasq arguments
authorJiri Denemark <jdenemar@redhat.com>
Wed, 11 Aug 2010 15:47:18 +0000 (17:47 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 11 Aug 2010 18:42:08 +0000 (20:42 +0200)
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

index 59e02b1f1b3a94ad7730df536350d40411755493..f247a0f9b19d1932566a0c385e26721e0b1732b8 100644 (file)
@@ -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 */