提交 318d54e5 编写于 作者: M Michal Privoznik

virnetdevtap: Don't crash on !ifname in virNetDevTapInterfaceStats

https://bugzilla.redhat.com/show_bug.cgi?id=1595184

Some domain <interfaces/> do not have a name (because they are
not TAP devices). Therefore, if
virNetDevTapInterfaceStats(net->ifname, ...) is called an instant
crash occurs. In Linux version of the function strlen() is called
over the name and in BSD version STREQ() is called.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NAndrea Bolognani <abologna@redhat.com>
上级 40859848
......@@ -691,6 +691,12 @@ virNetDevTapInterfaceStats(const char *ifname,
FILE *fp;
char line[256], *colon;
if (!ifname) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Interface name not provided"));
return -1;
}
fp = fopen("/proc/net/dev", "r");
if (!fp) {
virReportSystemError(errno, "%s",
......@@ -768,6 +774,12 @@ virNetDevTapInterfaceStats(const char *ifname,
struct if_data *ifd;
int ret = -1;
if (!ifname) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Interface name not provided"));
return -1;
}
if (getifaddrs(&ifap) < 0) {
virReportSystemError(errno, "%s",
_("Could not get interface list"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册