libvirt/SOURCES/libvirt-vircgroupv2-fix-parsing-multiple-values-in-single-file.patch
2021-09-10 11:57:18 +00:00

106 lines
4.4 KiB
Diff

From ae178683071d3948d1d1da6205726a3e24923b45 Mon Sep 17 00:00:00 2001
Message-Id: <ae178683071d3948d1d1da6205726a3e24923b45@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Wed, 21 Aug 2019 09:42:34 +0200
Subject: [PATCH] vircgroupv2: fix parsing multiple values in single file
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 <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit c854e0bd33c7a5afb04a36465bf04f861b2efef5)
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <49fe97f452eb4247040b1f322d348a3eea931efe.1566373284.git.phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@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 9ae47e775e..e129686a52 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -672,7 +672,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);
@@ -868,7 +868,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);
@@ -938,7 +938,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);
@@ -1009,7 +1009,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);
@@ -1080,7 +1080,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);
@@ -1151,7 +1151,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);
@@ -1534,7 +1534,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;
@@ -1584,7 +1584,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.23.0