Fix some more memory issues
authorSteven Barth <steven@midlink.org>
Tue, 15 Oct 2013 08:54:15 +0000 (10:54 +0200)
committerSteven Barth <steven@midlink.org>
Tue, 15 Oct 2013 08:54:15 +0000 (10:54 +0200)
src/odhcpd.c
src/router.c

index 6070bfb7904c592ccbda36de8e7944ebdeb32c7e..acedaec0b13cf26cef5dc72cfd5bf4ed56506ab9 100644 (file)
@@ -131,6 +131,7 @@ int odhcpd_get_interface_mtu(const char *ifname)
 int odhcpd_get_mac(const struct interface *iface, uint8_t mac[6])
 {
        struct ifreq ifr;
+       memset(&ifr, 0, sizeof(ifr));
        strncpy(ifr.ifr_name, iface->ifname, sizeof(ifr.ifr_name));
        if (ioctl(ioctl_sock, SIOCGIFHWADDR, &ifr) < 0)
                return -1;
index 9258acf00869be69f2299daae87e91040239a8b3..bb7ddcd27e5c1f045ce90998f2fb96006a867f23 100644 (file)
@@ -352,7 +352,7 @@ static void send_router_advert(struct uloop_timeout *event)
                uint8_t pad2;
                uint32_t lifetime;
                uint8_t name[];
-       } *search = alloca(sizeof(*search) + search_padded);
+       } *search = malloc(sizeof(*search) + search_padded);
        search->type = ND_OPT_DNS_SEARCH;
        search->len = search_len ? ((sizeof(*search) + search_padded) / 8) : 0;
        search->pad = 0;
@@ -409,6 +409,7 @@ static void send_router_advert(struct uloop_timeout *event)
        struct sockaddr_in6 all_nodes = {AF_INET6, 0, 0, ALL_IPV6_NODES, 0};
        odhcpd_send(router_event.uloop.fd,
                        &all_nodes, iov, ARRAY_SIZE(iov), iface);
+       free(search);
 
        // Rearm timer
        int msecs;