* src/conf.[ch]: restrict VMX syntax parsing types

daniel
This commit is contained in:
Daniel Veillard 2009-06-22 11:54:49 +00:00
parent c57932c663
commit a06b407fce
3 changed files with 19 additions and 3 deletions

View File

@ -1,3 +1,8 @@
Mon Jun 22 12:27:39 CEST 2009 Daniel Veillard <veillard@redhat.com>
* src/conf.[ch]: restrict VMX syntax parsing types, patch by Matthias
Bolte
Mon Jun 22 12:14:48 CEST 2009 Daniel Veillard <veillard@redhat.com>
* src/storage_driver.c: cleanup when creating a storage pool fails,

View File

@ -447,6 +447,11 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
if (str == NULL)
return(NULL);
} else if (CUR == '[') {
if (ctxt->conf->flags & VIR_CONF_FLAG_VMX_FORMAT) {
virConfError(ctxt, VIR_ERR_CONF_SYNTAX,
_("lists not allowed in VMX format"));
return(NULL);
}
type = VIR_CONF_LIST;
NEXT;
SKIP_BLANKS_AND_EOL;
@ -486,6 +491,11 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
return(NULL);
}
} else if (c_isdigit(CUR) || (CUR == '-') || (CUR == '+')) {
if (ctxt->conf->flags & VIR_CONF_FLAG_VMX_FORMAT) {
virConfError(ctxt, VIR_ERR_CONF_SYNTAX,
_("numbers not allowed in VMX format"));
return(NULL);
}
if (virConfParseLong(ctxt, &l) < 0) {
return(NULL);
}
@ -530,7 +540,7 @@ virConfParseName(virConfParserCtxtPtr ctxt)
}
while ((ctxt->cur < ctxt->end) &&
(c_isalnum(CUR) || (CUR == '_') ||
((ctxt->conf->flags & VIR_CONF_FLAG_ALLOW_VMX_NAMES) &&
((ctxt->conf->flags & VIR_CONF_FLAG_VMX_FORMAT) &&
((CUR == ':') || (CUR == '.')))))
NEXT;
ret = strndup(base, ctxt->cur - base);

View File

@ -25,8 +25,9 @@ typedef enum {
} virConfType;
typedef enum {
VIR_CONF_FLAG_ALLOW_VMX_NAMES = 1, /* allow : and . in names for compatibility
with VMware VMX configuration file */
VIR_CONF_FLAG_VMX_FORMAT = 1, /* allow : and . in names for compatibility with
VMware VMX configuration file, but restrict
allowed value types to string only */
} virConfFlags;
static inline const char *