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

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

 



Commit-ID:  a2a7af4c58f76b5e724f850a9b4b70f49bc5086c
Gitweb:     http://git.kernel.org/tip/a2a7af4c58f76b5e724f850a9b4b70f49bc5086c
Author:     Michael Ellerman <michael@xxxxxxxxxxxxxx>
AuthorDate: Fri, 10 Aug 2012 15:01:23 +1000
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Mon, 13 Aug 2012 10:29:08 +0300

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

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.

Acked-by: Asias He <asias.hejun@xxxxxxxxx>
Signed-off-by: Michael Ellerman <michael@xxxxxxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/net/uip/dhcp.c |    3 +--
 1 files changed, 1 insertions(+), 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;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux