[PATCH] kvm tools: Fix crash when /etc/resolv.conf doesn't exist

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

 



In uip_dhcp_get_dns() we try to open /etc/resolv.conf. If we fail to
open it we then SEGV trying to fclose() it.

Fix the code to just return directly if we can't open it.

Signed-off-by: Michael Ellerman <michael@xxxxxxxxxxxxxx>
---
 tools/kvm/net/uip/dhcp.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/kvm/net/uip/dhcp.c b/tools/kvm/net/uip/dhcp.c
index e91a7c7..b17d352 100644
--- a/tools/kvm/net/uip/dhcp.c
+++ b/tools/kvm/net/uip/dhcp.c
@@ -45,7 +45,7 @@ int uip_dhcp_get_dns(struct uip_info *info)
 
 	fp = fopen("/etc/resolv.conf", "r");
 	if (!fp)
-		goto out;
+		return ret;
 
 	while (!feof(fp)) {
 		if (fscanf(fp, "%s %s\n", key, val) != 2)
@@ -62,7 +62,6 @@ int uip_dhcp_get_dns(struct uip_info *info)
 		}
 	}
 
-out:
 	fclose(fp);
 	return ret;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux