From nobody Sat Feb 7 10:50:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498065086400689.676766087016; Wed, 21 Jun 2017 10:11:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC6AC7F3F2; Wed, 21 Jun 2017 17:11:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A14CB5C7A9; Wed, 21 Jun 2017 17:11:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5C6454E982; Wed, 21 Jun 2017 17:11:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5LHBLEf003653 for ; Wed, 21 Jun 2017 13:11:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7E46A60470; Wed, 21 Jun 2017 17:11:21 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77E1B5C7A9 for ; Wed, 21 Jun 2017 17:11:17 +0000 (UTC) Received: from mail-qt0-f196.google.com (mail-qt0-f196.google.com [209.85.216.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECB3B61A14 for ; Wed, 21 Jun 2017 17:11:15 +0000 (UTC) Received: by mail-qt0-f196.google.com with SMTP id c20so4162640qte.0 for ; Wed, 21 Jun 2017 10:11:15 -0700 (PDT) Received: from localhost.localdomain ([187.107.181.84]) by smtp.googlemail.com with ESMTPSA id z51sm2089465qtz.11.2017.06.21.10.10.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jun 2017 10:11:14 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CC6AC7F3F2 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CC6AC7F3F2 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KopRY0cC" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ECB3B61A14 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jcfaracco@gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ECB3B61A14 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=sSs1Ys5YXm2+QpPIQ/fHZ+qvj9lgh1+YqaTMqPWrbZg=; b=KopRY0cCqRKJbx65tIru0ueqtOway+x2dtTe20NVIDrOS0eTgrNtKw7HeXC6+FOYbe 0VA5dPoc6GELxkMfFNX2Xi06IbzNQrrX8bPTVo8HEeTDDPCAhn6UtZAVBVEfwoT9372O Eku2iMabvRhvpkuNKfaE5zwj6HmwJ9VEBTVWM2PkOUrJ4lNx0DLxAcWFtfzhNAidVF4k aOnD+H9/Nm/+3QtXSiKlZyHHl3EgPuD8ziuc2RAUSTy6zUiv9hyXxSeZrPfUB7eT2p3z S7pfDTwndUCFaBPAycDZRIsl1HnIE5xtPmvON+sDQ7crkHwHvYZIOyyVH5mc+0JnAS2d nuaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=sSs1Ys5YXm2+QpPIQ/fHZ+qvj9lgh1+YqaTMqPWrbZg=; b=YSPqYNhw09SAH21f8iRqpYJaEeMwso6UXkIsRL+eV1StbI9jBG8vkUM++ytK1MdS7z CKtoy8e5fYSTdhOqZ3sfGMR2l+HCtitaUue3GGgLtx3mbAFbmLgbME64yOk2n3YwQJ39 8Xny/CKO1/N0XIzVurPpwpTcjqu4EWmMKpwi91n8EQy16t2kIJsQL1oUs7a8pbKWM96Q zXOcwgGhKyQMt+xuc97yOEBI2a3gGRi2gR5dSUzWE46vDBtiSK8466KvAlt6mwL4e7jK 6HM4PXD7MZXylW0f22NSDu2XYvziZZdgHaVFcCp3075j0vxyw7CrQi8iqc0aUW71MA0D 0Oew== X-Gm-Message-State: AKS2vOx4pD81VjtekirYMM6258x9kLlP+I6+S9iVXAs5PRuVcu3lDN2d AsbhVSjlVoyQBi29 X-Received: by 10.237.33.78 with SMTP id 72mr38618329qtc.99.1498065074953; Wed, 21 Jun 2017 10:11:14 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Wed, 21 Jun 2017 14:08:29 -0300 Message-Id: <1498064909-8189-3-git-send-email-jcfaracco@gmail.com> In-Reply-To: <1498064909-8189-1-git-send-email-jcfaracco@gmail.com> References: <1498064909-8189-1-git-send-email-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 21 Jun 2017 17:11:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 21 Jun 2017 17:11:16 +0000 (UTC) for IP:'209.85.216.196' DOMAIN:'mail-qt0-f196.google.com' HELO:'mail-qt0-f196.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.67 (BAYES_50, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.216.196 mail-qt0-f196.google.com 209.85.216.196 mail-qt0-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 2/2] util: fix locale problem with virStrToDouble(). X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 21 Jun 2017 17:11:24 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This commit fixes a locale problem with locales that use comma as a mantissa separator. Example: 12.34 en_US =3D 12,34 pt_BR. Since strtod() is a non-sa= fe function, virStrToDouble() will have problems to parse double numbers from kernel settings and other double numbers from static files (XMLs, JSONs, et= c). Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1457634 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1457481 Signed-off-by: Julio Faracco --- src/util/virstring.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/util/virstring.c b/src/util/virstring.c index 9c12f7b..1bd6777 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -534,7 +534,13 @@ virLocaleOnceInit(void) VIR_ONCE_GLOBAL_INIT(virLocale); #endif =20 - +/** + * virStrToDouble + * + * converts string with C locale (thread-safe) to double. + * + * Returns -1 on error or returns 0 on success. + */ int virStrToDouble(char const *s, char **end_ptr, @@ -545,7 +551,17 @@ virStrToDouble(char const *s, int err; =20 errno =3D 0; +#if HAVE_NEWLOCALE + locale_t old_loc; + if (virLocaleInitialize() < 0) + return -1; + + old_loc =3D uselocale(virLocale); +#endif val =3D strtod(s, &p); /* exempt from syntax-check */ +#if HAVE_NEWLOCALE + uselocale(old_loc); +#endif err =3D (errno || (!end_ptr && *p) || p =3D=3D s); if (end_ptr) *end_ptr =3D p; --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list