[libvirt] [PATCHv2 1/2] virDomainSaveXML: Reject domains which name contain '/'
Jim Fehlig
jfehlig at suse.com
Fri Feb 8 18:44:54 UTC 2013
John Ferlan wrote:
> On 02/07/2013 08:27 AM, Christophe Fergeau wrote:
>
>> Similarly to 790f912b4 which rejects snapshots names containing,
>> this commit changes virDomainSaveXML to reject domains with a '/'
>> in their name. The domain name is used as a filename, so this
>> leads to unexpected results when used in combination with '..'
>> ---
>> src/conf/domain_conf.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> index 85a798d..13f4bc0 100644
>> --- a/src/conf/domain_conf.c
>> +++ b/src/conf/domain_conf.c
>> @@ -14728,6 +14728,13 @@ int virDomainSaveXML(const char *configDir,
>> char *configFile = NULL;
>> int ret = -1;
>>
>> + if (strchr(def->name, '/')) {
>> + virReportError(VIR_ERR_XML_DETAIL,
>> + _("invalid domain name '%s': name can't contain '/'"),
>> + def->name);
>> + goto cleanup;
>> + }
>> +
>> if ((configFile = virDomainConfigFile(configDir, def->name)) == NULL)
>> goto cleanup;
>>
>>
>>
> Seems this should be in a more "general" location. Would the same rules apply to
> other objects (networks, storage, etc.)? What other characters should be avoided?
> Having a comma, semi-colon, colon, etc. could have interesting results.
Yeah, comma is an interesting one for qemu since that delimits option
subarguments. E.g. trying to start a qemu instance with name 'foo,bar'
results in
$ virsh start "foo,bar"
error: Failed to start domain foo,bar
error: internal error process exited while connecting to monitor:
Unknown subargument bar to -name
Regards,
Jim
More information about the libvir-list
mailing list