render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
c480ed
From ae178683071d3948d1d1da6205726a3e24923b45 Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <ae178683071d3948d1d1da6205726a3e24923b45@dist-git>
c480ed
From: Pavel Hrdina <phrdina@redhat.com>
c480ed
Date: Wed, 21 Aug 2019 09:42:34 +0200
c480ed
Subject: [PATCH] vircgroupv2: fix parsing multiple values in single file
c480ed
c480ed
Our virStrToLong* helpers converts string to integers where it wraps
c480ed
strtol standard function.  After the conversion happens and there are
c480ed
some remaining invalid characters our helpers will fail if the second
c480ed
argument is NULL.
c480ed
c480ed
We need to pass pointer to string in cases where there are multiple
c480ed
values in a single file.
c480ed
c480ed
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1741825
c480ed
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
(cherry picked from commit c854e0bd33c7a5afb04a36465bf04f861b2efef5)
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
Message-Id: <49fe97f452eb4247040b1f322d348a3eea931efe.1566373284.git.phrdina@redhat.com>
c480ed
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
---
c480ed
 src/util/vircgroupv2.c | 16 ++++++++--------
c480ed
 1 file changed, 8 insertions(+), 8 deletions(-)
c480ed
c480ed
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
c480ed
index 9ae47e775e..e129686a52 100644
c480ed
--- a/src/util/vircgroupv2.c
c480ed
+++ b/src/util/vircgroupv2.c
c480ed
@@ -672,7 +672,7 @@ virCgroupV2GetBlkioWeight(virCgroupPtr group,
c480ed
         tmp = value;
c480ed
     }
c480ed
 
c480ed
-    if (virStrToLong_ui(tmp, NULL, 10, weight) < 0) {
c480ed
+    if (virStrToLong_ui(tmp, &tmp, 10, weight) < 0) {
c480ed
         virReportError(VIR_ERR_INTERNAL_ERROR,
c480ed
                        _("Unable to parse '%s' as an integer"),
c480ed
                        tmp);
c480ed
@@ -868,7 +868,7 @@ virCgroupV2GetBlkioDeviceWeight(virCgroupPtr group,
c480ed
 
c480ed
     if (!str) {
c480ed
         *weight = 0;
c480ed
-    } else if (virStrToLong_ui(str, NULL, 10, weight) < 0) {
c480ed
+    } else if (virStrToLong_ui(str, &str, 10, weight) < 0) {
c480ed
         virReportError(VIR_ERR_INTERNAL_ERROR,
c480ed
                        _("Unable to parse '%s' as an integer"),
c480ed
                        str);
c480ed
@@ -938,7 +938,7 @@ virCgroupV2GetBlkioDeviceReadIops(virCgroupPtr group,
c480ed
 
c480ed
         if (STREQLEN(tmp, "max", 3)) {
c480ed
             *riops = 0;
c480ed
-        } else if (virStrToLong_ui(tmp, NULL, 10, riops) < 0) {
c480ed
+        } else if (virStrToLong_ui(tmp, &tmp, 10, riops) < 0) {
c480ed
             virReportError(VIR_ERR_INTERNAL_ERROR,
c480ed
                            _("Unable to parse '%s' as an integer"),
c480ed
                            str);
c480ed
@@ -1009,7 +1009,7 @@ virCgroupV2GetBlkioDeviceWriteIops(virCgroupPtr group,
c480ed
 
c480ed
         if (STREQLEN(tmp, "max", 3)) {
c480ed
             *wiops = 0;
c480ed
-        } else if (virStrToLong_ui(tmp, NULL, 10, wiops) < 0) {
c480ed
+        } else if (virStrToLong_ui(tmp, &tmp, 10, wiops) < 0) {
c480ed
             virReportError(VIR_ERR_INTERNAL_ERROR,
c480ed
                            _("Unable to parse '%s' as an integer"),
c480ed
                            str);
c480ed
@@ -1080,7 +1080,7 @@ virCgroupV2GetBlkioDeviceReadBps(virCgroupPtr group,
c480ed
 
c480ed
         if (STREQLEN(tmp, "max", 3)) {
c480ed
             *rbps = 0;
c480ed
-        } else if (virStrToLong_ull(tmp, NULL, 10, rbps) < 0) {
c480ed
+        } else if (virStrToLong_ull(tmp, &tmp, 10, rbps) < 0) {
c480ed
             virReportError(VIR_ERR_INTERNAL_ERROR,
c480ed
                            _("Unable to parse '%s' as an integer"),
c480ed
                            str);
c480ed
@@ -1151,7 +1151,7 @@ virCgroupV2GetBlkioDeviceWriteBps(virCgroupPtr group,
c480ed
 
c480ed
         if (STREQLEN(tmp, "max", 3)) {
c480ed
             *wbps = 0;
c480ed
-        } else if (virStrToLong_ull(tmp, NULL, 10, wbps) < 0) {
c480ed
+        } else if (virStrToLong_ull(tmp, &tmp, 10, wbps) < 0) {
c480ed
             virReportError(VIR_ERR_INTERNAL_ERROR,
c480ed
                            _("Unable to parse '%s' as an integer"),
c480ed
                            str);
c480ed
@@ -1534,7 +1534,7 @@ virCgroupV2GetCpuCfsPeriod(virCgroupPtr group,
c480ed
         return -1;
c480ed
     }
c480ed
 
c480ed
-    if (virStrToLong_ull(tmp, NULL, 10, cfs_period) < 0) {
c480ed
+    if (virStrToLong_ull(tmp, &tmp, 10, cfs_period) < 0) {
c480ed
         virReportError(VIR_ERR_INTERNAL_ERROR,
c480ed
                        _("Failed to parse value '%s' from cpu.max."), str);
c480ed
         return -1;
c480ed
@@ -1584,7 +1584,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group,
c480ed
     if (STREQLEN(str, "max", 3))
c480ed
         *cfs_quota = ULLONG_MAX / 1000;
c480ed
 
c480ed
-    if (virStrToLong_ll(str, NULL, 10, cfs_quota) < 0) {
c480ed
+    if (virStrToLong_ll(str, &str, 10, cfs_quota) < 0) {
c480ed
         virReportError(VIR_ERR_INTERNAL_ERROR,
c480ed
                        _("Failed to parse value '%s' from cpu.max."), str);
c480ed
         return -1;
c480ed
-- 
c480ed
2.23.0
c480ed