Re: [PATCH] (for discussion) DHCP host mappings using 3 arrays API

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

 



"Richard W.M. Jones" <rjones@xxxxxxxxxx> wrote:
> Here's the final version of the "3 arrays" version of the patch, with
> the memory corruptor fixed.
...
> Index: src/qemu_driver.c
> ===================================================================
> RCS file: /data/cvs/libvirt/src/qemu_driver.c,v
> retrieving revision 1.57
> diff -u -r1.57 qemu_driver.c
> --- src/qemu_driver.c	27 Feb 2008 04:37:07 -0000	1.57
> +++ src/qemu_driver.c	27 Feb 2008 16:08:34 -0000
> @@ -925,6 +930,7 @@
>  dhcpStartDhcpDaemon(virConnectPtr conn,
>                      struct qemud_network *network)
>  {
> +    char buf[PATH_MAX];
>      char **argv;
>      int ret, i;
>
> @@ -934,6 +940,15 @@
>          return -1;
>      }
>
> +    /* Touch the DHCP hosts file so it exists before dnsmasq starts up. */
> +    snprintf (buf, sizeof buf, DHCP_HOSTS_FORMAT, network->def->name);
> +    ret = open (buf, O_CREAT|O_WRONLY, 0644);
> +    if (ret == -1) {
> +        qemudReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR,
> +                          "%s: %s", buf, strerror (errno));
> +        return -1;
> +    }
> +
>      argv = NULL;
>      if (qemudBuildDnsmasqArgv(conn, network, &argv) < 0)
>          return -1;

Whoops.  You'll want to close that file descriptor.
E.g., put this right before "argv = NULL;":

    if (close (ret))
        return -1;

It'd be nice to declare a new variable, say fd, for that bit.

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