mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-04 20:51:28 +00:00
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@gmail.com> Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
committed by
Will Deacon
parent
3258566626
commit
a7b946b905
+1
-2
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user