]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[dns] Fix memory leak in settings applicator
authorMichael Brown <mcb30@ipxe.org>
Thu, 3 Mar 2011 20:09:29 +0000 (20:09 +0000)
committerMichael Brown <mcb30@ipxe.org>
Thu, 3 Mar 2011 20:09:29 +0000 (20:09 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/udp/dns.c

index be7a98e7f14d4a781bd18e6b897485b2dad0e702..2326284bf321d1da704aceb216f774b7cbf88d08 100644 (file)
@@ -612,16 +612,23 @@ static int apply_dns_settings ( void ) {
                ( struct sockaddr_in * ) &nameserver;
        int len;
 
+       /* Fetch DNS server address */
+       nameserver.st_family = 0;
        if ( ( len = fetch_ipv4_setting ( NULL, &dns_setting,
                                          &sin_nameserver->sin_addr ) ) >= 0 ){
-               sin_nameserver->sin_family = AF_INET;
+               nameserver.st_family = AF_INET;
                DBG ( "DNS using nameserver %s\n",
                      inet_ntoa ( sin_nameserver->sin_addr ) );
        }
 
        /* Get local domain DHCP option */
+       free ( localdomain );
        if ( ( len = fetch_string_setting_copy ( NULL, &domain_setting,
-                                                &localdomain ) ) >= 0 )
+                                                &localdomain ) ) < 0 ) {
+               DBG ( "DNS could not fetch local domain: %s\n",
+                     strerror ( len ) );
+       }
+       if ( localdomain )
                DBG ( "DNS local domain %s\n", localdomain );
 
        return 0;