Message ID | 1344574883-13503-1-git-send-email-michael@ellerman.id.au (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Aug 10, 2012 at 1:01 PM, Michael Ellerman <michael@ellerman.id.au> wrote: > 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@ellerman.id.au> > --- > 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 > Acked-by: Asias He <asias.hejun@gmail.com>
I've applied all Michal's patches. Thanks guys! -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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; }
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@ellerman.id.au> --- tools/kvm/net/uip/dhcp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)