]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Fix crash when /etc/resolv.conf doesn't exist
authorMichael Ellerman <michael@ellerman.id.au>
Fri, 10 Aug 2012 05:01:23 +0000 (15:01 +1000)
committerPekka Enberg <penberg@kernel.org>
Mon, 13 Aug 2012 07:29:08 +0000 (10:29 +0300)
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@gmail.com>
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/net/uip/dhcp.c

index e91a7c7a6aca4584283cebea05ab281d39434b71..b17d35239321155e5b518d94ff5dd861074372fe 100644 (file)
@@ -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;
 }