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