瀏覽代碼

[dns] Fix memory leak in settings applicator

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 年之前
父節點
當前提交
bbe265e08b
共有 1 個文件被更改,包括 9 次插入2 次删除
  1. 9
    2
      src/net/udp/dns.c

+ 9
- 2
src/net/udp/dns.c 查看文件

@@ -612,16 +612,23 @@ static int apply_dns_settings ( void ) {
612 612
 		( struct sockaddr_in * ) &nameserver;
613 613
 	int len;
614 614
 
615
+	/* Fetch DNS server address */
616
+	nameserver.st_family = 0;
615 617
 	if ( ( len = fetch_ipv4_setting ( NULL, &dns_setting,
616 618
 					  &sin_nameserver->sin_addr ) ) >= 0 ){
617
-		sin_nameserver->sin_family = AF_INET;
619
+		nameserver.st_family = AF_INET;
618 620
 		DBG ( "DNS using nameserver %s\n",
619 621
 		      inet_ntoa ( sin_nameserver->sin_addr ) );
620 622
 	}
621 623
 
622 624
 	/* Get local domain DHCP option */
625
+	free ( localdomain );
623 626
 	if ( ( len = fetch_string_setting_copy ( NULL, &domain_setting,
624
-						 &localdomain ) ) >= 0 )
627
+						 &localdomain ) ) < 0 ) {
628
+		DBG ( "DNS could not fetch local domain: %s\n",
629
+		      strerror ( len ) );
630
+	}
631
+	if ( localdomain )
625 632
 		DBG ( "DNS local domain %s\n", localdomain );
626 633
 
627 634
 	return 0;

Loading…
取消
儲存