mirror of https://gitee.com/openkylin/libvirt.git
conf: Always use 'string()' conversion with virXPath(U)LongLong
When the 'string()' conversion is used the number is parsed inside libvirt by our internal helpers which work on integers in contrast to when 'number()' is used and libxml2 uses a 'double' variable internally. On the upper extremes of the 64 bit variables the double precision variable doesn't have enough precision to represent each distinct integer and thus could cause problems. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
3ae376535a
commit
8525ac4b83
|
@ -18103,10 +18103,10 @@ virDomainDefClockParse(virDomainDef *def,
|
|||
break;
|
||||
|
||||
case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE:
|
||||
if (virXPathLongLong("number(./clock/@adjustment)", ctxt,
|
||||
if (virXPathLongLong("string(./clock/@adjustment)", ctxt,
|
||||
&def->clock.data.variable.adjustment) < 0)
|
||||
def->clock.data.variable.adjustment = 0;
|
||||
if (virXPathLongLong("number(./clock/@adjustment0)", ctxt,
|
||||
if (virXPathLongLong("string(./clock/@adjustment0)", ctxt,
|
||||
&def->clock.data.variable.adjustment0) < 0)
|
||||
def->clock.data.variable.adjustment0 = 0;
|
||||
tmp = virXPathString("string(./clock/@basis)", ctxt);
|
||||
|
@ -18132,7 +18132,7 @@ virDomainDefClockParse(virDomainDef *def,
|
|||
break;
|
||||
|
||||
case VIR_DOMAIN_CLOCK_OFFSET_ABSOLUTE:
|
||||
if (virXPathULongLong("number(./clock/@start)", ctxt,
|
||||
if (virXPathULongLong("string(./clock/@start)", ctxt,
|
||||
&def->clock.data.starttime) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("missing 'start' attribute for clock with offset='absolute'"));
|
||||
|
|
|
@ -1463,7 +1463,7 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt,
|
|||
storage->media_label = virXPathString("string(./media_label[1])", ctxt);
|
||||
|
||||
val = 0;
|
||||
if (virNodeDevCapsDefParseULongLong("number(./media_size[1])", ctxt, &val, def,
|
||||
if (virNodeDevCapsDefParseULongLong("string(./media_size[1])", ctxt, &val, def,
|
||||
_("no removable media size supplied for '%s'"),
|
||||
_("invalid removable media size supplied for '%s'")) < 0) {
|
||||
return -1;
|
||||
|
@ -1481,7 +1481,7 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt,
|
|||
|
||||
if (!(storage->flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE)) {
|
||||
val = 0;
|
||||
if (virNodeDevCapsDefParseULongLong("number(./size[1])", ctxt, &val, def,
|
||||
if (virNodeDevCapsDefParseULongLong("string(./size[1])", ctxt, &val, def,
|
||||
_("no size supplied for '%s'"),
|
||||
_("invalid size supplied for '%s'")) < 0)
|
||||
return -1;
|
||||
|
|
|
@ -720,7 +720,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
|
|||
perms->uid = (uid_t) -1;
|
||||
} else {
|
||||
/* We previously could output -1, so continue to parse it */
|
||||
if (virXPathLongLong("number(./owner)", ctxt, &val) < 0 ||
|
||||
if (virXPathLongLong("string(./owner)", ctxt, &val) < 0 ||
|
||||
((uid_t)val != val &&
|
||||
val != -1)) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
|
@ -735,7 +735,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
|
|||
perms->gid = (gid_t) -1;
|
||||
} else {
|
||||
/* We previously could output -1, so continue to parse it */
|
||||
if (virXPathLongLong("number(./group)", ctxt, &val) < 0 ||
|
||||
if (virXPathLongLong("string(./group)", ctxt, &val) < 0 ||
|
||||
((gid_t) val != val &&
|
||||
val != -1)) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
|
|
Loading…
Reference in New Issue