[libvirt] [PATCH] vircgroupv2: fix abort in VIR_AUTOFREE

Pavel Hrdina posted 1 patch 5 years, 2 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/6369cc4d33a61c42cd577d0601d4c0ff3e9a0b98.1567174900.git.phrdina@redhat.com
src/util/vircgroupv2.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[libvirt] [PATCH] vircgroupv2: fix abort in VIR_AUTOFREE
Posted by Pavel Hrdina 5 years, 2 months ago
Introduced by commit <c854e0bd33c7a5afb04a36465bf04f861b2efef5> that
tried to fix an issue where we would fail to parse values from files.

We cannot change the original pointer that is going to be used by
VIR_AUTOFREE.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---

Sigh, shame on me!

 src/util/vircgroupv2.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index c62ee0d933..2aca4e5d62 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -849,6 +849,7 @@ virCgroupV2GetBlkioDeviceWeight(virCgroupPtr group,
     VIR_AUTOFREE(char *) path = NULL;
     VIR_AUTOFREE(char *) str = NULL;
     VIR_AUTOFREE(char *) value = NULL;
+    char *tmp;
 
     if (virCgroupV2PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
                                     "io.weight", &path) < 0) {
@@ -869,7 +870,7 @@ virCgroupV2GetBlkioDeviceWeight(virCgroupPtr group,
 
     if (!str) {
         *weight = 0;
-    } else if (virStrToLong_ui(str, &str, 10, weight) < 0) {
+    } else if (virStrToLong_ui(str, &tmp, 10, weight) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Unable to parse '%s' as an integer"),
                        str);
@@ -1576,6 +1577,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group,
                           long long *cfs_quota)
 {
     VIR_AUTOFREE(char *) str = NULL;
+    char *tmp;
 
     if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPU,
                              "cpu.max", &str) < 0) {
@@ -1587,7 +1589,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group,
         return 0;
     }
 
-    if (virStrToLong_ll(str, &str, 10, cfs_quota) < 0) {
+    if (virStrToLong_ll(str, &tmp, 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
Re: [libvirt] [PATCH] vircgroupv2: fix abort in VIR_AUTOFREE
Posted by Peter Krempa 5 years, 2 months ago
On Fri, Aug 30, 2019 at 16:26:23 +0200, Pavel Hrdina wrote:
> Introduced by commit <c854e0bd33c7a5afb04a36465bf04f861b2efef5> that
> tried to fix an issue where we would fail to parse values from files.
> 
> We cannot change the original pointer that is going to be used by
> VIR_AUTOFREE.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1747440
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
> 
> Sigh, shame on me!

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