From nobody Sun Feb 8 19:59:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1666620990; cv=none; d=zohomail.com; s=zohoarc; b=bWi5J8IQgOMy6ZVq57ZXnd3s+3ozJvbqi/CHUwknL2hmw2FG9fjToxIJO7xvHawkJ+SmeZ0+Xut2HRoTWnWOH2BYFq50hMhbjY0ovuv8QLcERj58kIUCw5ZBDkmJthYBlZiqLvCTruQ4OMYBXNsq7rRfBhJ7A6qxa07YWpjxzAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620990; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s0k+RgqLQyQCQ3YAA4h7Ap4DRY5nuROyBGUeyFlD9AM=; b=aGgLAShVuD/FmxUDa+ZiJozV9Bi0B8GetSjTPQJgR29xwZVtRk3w81zGpVJ2UHXVp3lhiS9eS6mBHeTp+DppkeBSL1EQLK67y4fd9A4tft8ofzSQyeWDk1X9hgkklqCklH+GxeQrNHzxOEXsTjdX/me3pSSCuz2S/LPhSvK+zUc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1666620990891537.3390792616646; Mon, 24 Oct 2022 07:16:30 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-414-SXhnCrLdOvadjaiuTBjYXg-1; Mon, 24 Oct 2022 10:16:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4A84F2A5954B; Mon, 24 Oct 2022 14:15:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 339DC40C6F75; Mon, 24 Oct 2022 14:15:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2685F194658F; Mon, 24 Oct 2022 14:15:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6F505194658F for ; Mon, 24 Oct 2022 14:15:06 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5527E40C2143; Mon, 24 Oct 2022 14:15:06 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF3DD40C2089 for ; Mon, 24 Oct 2022 14:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620989; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=s0k+RgqLQyQCQ3YAA4h7Ap4DRY5nuROyBGUeyFlD9AM=; b=XjV74paIvXvVzE772k5W5oWAkV6iRsa3gKf/JuTDdgDmCIcmHs4d+WoaIdupS4tQwNVM2d ehN76HoAODemySqcf8VhN0d27Y4lMn1vPguMLYV8DayWGa1kqMlN4RZ6nWlRlLj5aI5F/4 +MwrfcV0WF0g0u8dxeaW4Fz3ZoDtNLs= X-MC-Unique: SXhnCrLdOvadjaiuTBjYXg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/43] conf: Always use 'string()' conversion with virXPath(U)LongLong Date: Mon, 24 Oct 2022 16:14:14 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666620992521100004 Content-Type: text/plain; charset="utf-8" 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 doulbe precision variable doesn't have enough precision to represent each distinct integer and thus could cause problems. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 6 +++--- src/conf/node_device_conf.c | 4 ++-- src/conf/storage_conf.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7dba65cfeb..7984a15c46 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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 =3D 0; - if (virXPathLongLong("number(./clock/@adjustment0)", ctxt, + if (virXPathLongLong("string(./clock/@adjustment0)", ctxt, &def->clock.data.variable.adjustment0) < 0) def->clock.data.variable.adjustment0 =3D 0; tmp =3D 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 off= set=3D'absolute'")); diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index b079c3713d..3bff17dae2 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1463,7 +1463,7 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, storage->media_label =3D virXPathString("string(./media_label[= 1])", ctxt); val =3D 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 =3D 0; - if (virNodeDevCapsDefParseULongLong("number(./size[1])", ctxt, &va= l, def, + if (virNodeDevCapsDefParseULongLong("string(./size[1])", ctxt, &va= l, def, _("no size supplied for '%s'"), _("invalid size supplied for '= %s'")) < 0) return -1; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 0f4fe1451e..b570679de2 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -720,7 +720,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, perms->uid =3D (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 !=3D val && val !=3D -1)) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -735,7 +735,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, perms->gid =3D (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 !=3D val && val !=3D -1)) { virReportError(VIR_ERR_XML_ERROR, "%s", --=20 2.37.3