Our virStrToLong* helpers converts string to integers where it wraps
strtol standard function.  After the conversion happens and there are
some remaining invalid characters our helpers will fail if the second
argument is NULL.

We need to pass pointer to string in cases where there are multiple
values in a single file.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1741825

Signed-off-by: Pavel Hrdina <phrd...@redhat.com>
---
 src/util/vircgroupv2.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index e36c36685b..59ef2e6397 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -673,7 +673,7 @@ virCgroupV2GetBlkioWeight(virCgroupPtr group,
         tmp = value;
     }
 
-    if (virStrToLong_ui(tmp, NULL, 10, weight) < 0) {
+    if (virStrToLong_ui(tmp, &tmp, 10, weight) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Unable to parse '%s' as an integer"),
                        tmp);
@@ -869,7 +869,7 @@ virCgroupV2GetBlkioDeviceWeight(virCgroupPtr group,
 
     if (!str) {
         *weight = 0;
-    } else if (virStrToLong_ui(str, NULL, 10, weight) < 0) {
+    } else if (virStrToLong_ui(str, &str, 10, weight) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Unable to parse '%s' as an integer"),
                        str);
@@ -939,7 +939,7 @@ virCgroupV2GetBlkioDeviceReadIops(virCgroupPtr group,
 
         if (STREQLEN(tmp, "max", 3)) {
             *riops = 0;
-        } else if (virStrToLong_ui(tmp, NULL, 10, riops) < 0) {
+        } else if (virStrToLong_ui(tmp, &tmp, 10, riops) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Unable to parse '%s' as an integer"),
                            str);
@@ -1010,7 +1010,7 @@ virCgroupV2GetBlkioDeviceWriteIops(virCgroupPtr group,
 
         if (STREQLEN(tmp, "max", 3)) {
             *wiops = 0;
-        } else if (virStrToLong_ui(tmp, NULL, 10, wiops) < 0) {
+        } else if (virStrToLong_ui(tmp, &tmp, 10, wiops) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Unable to parse '%s' as an integer"),
                            str);
@@ -1081,7 +1081,7 @@ virCgroupV2GetBlkioDeviceReadBps(virCgroupPtr group,
 
         if (STREQLEN(tmp, "max", 3)) {
             *rbps = 0;
-        } else if (virStrToLong_ull(tmp, NULL, 10, rbps) < 0) {
+        } else if (virStrToLong_ull(tmp, &tmp, 10, rbps) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Unable to parse '%s' as an integer"),
                            str);
@@ -1152,7 +1152,7 @@ virCgroupV2GetBlkioDeviceWriteBps(virCgroupPtr group,
 
         if (STREQLEN(tmp, "max", 3)) {
             *wbps = 0;
-        } else if (virStrToLong_ull(tmp, NULL, 10, wbps) < 0) {
+        } else if (virStrToLong_ull(tmp, &tmp, 10, wbps) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Unable to parse '%s' as an integer"),
                            str);
@@ -1535,7 +1535,7 @@ virCgroupV2GetCpuCfsPeriod(virCgroupPtr group,
         return -1;
     }
 
-    if (virStrToLong_ull(tmp, NULL, 10, cfs_period) < 0) {
+    if (virStrToLong_ull(tmp, &tmp, 10, cfs_period) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Failed to parse value '%s' from cpu.max."), str);
         return -1;
@@ -1585,7 +1585,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group,
     if (STREQLEN(str, "max", 3))
         *cfs_quota = ULLONG_MAX / 1000;
 
-    if (virStrToLong_ll(str, NULL, 10, cfs_quota) < 0) {
+    if (virStrToLong_ll(str, &str, 10, cfs_quota) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Failed to parse value '%s' from cpu.max."), str);
         return -1;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to