提交 2f646237 编写于 作者: S Stefan Berger

Blank out invalid interface names with escaped letters etc.

Check that interface names only contain valid characters. Blank them out
otherwise.
Valid characters in this code are currently a-z,A-Z,0-9, '-' and '_'.
上级 ffbfd2c8
......@@ -1776,6 +1776,11 @@ cleanup:
}
static bool
isValidIfname(const char *ifname) {
return (strspn(ifname, VALID_IFNAME_CHARS) == strlen(ifname));
}
/* Parse the XML definition for a network interface
* @param node XML nodeset to parse for net definition
......@@ -1859,8 +1864,10 @@ virDomainNetDefParseXML(virCapsPtr caps,
xmlStrEqual(cur->name, BAD_CAST "target")) {
ifname = virXMLPropString(cur, "dev");
if ((ifname != NULL) &&
(STRPREFIX((const char*)ifname, "vnet"))) {
((STRPREFIX((const char*)ifname, "vnet")) ||
(!isValidIfname(ifname)))) {
/* An auto-generated target name, blank it out */
/* blank out invalid interface names */
VIR_FREE(ifname);
}
} else if ((script == NULL) &&
......
......@@ -297,6 +297,9 @@ struct _virDomainNetDef {
virNWFilterHashTablePtr filterparams;
};
# define VALID_IFNAME_CHARS \
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
enum virDomainChrTargetType {
VIR_DOMAIN_CHR_TARGET_TYPE_NULL = 0,
VIR_DOMAIN_CHR_TARGET_TYPE_MONITOR,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册