mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-27 18:03:50 +03:00
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 '_'.
This commit is contained in:
parent
ffbfd2c813
commit
2f646237da
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user