!31 Fix the invalid memory address reference

From: @maminjie
Reviewed-by: @wangxiao65,@caihaomin
Signed-off-by: @caihaomin
This commit is contained in:
openeuler-ci-bot 2021-03-15 14:29:58 +08:00 committed by Gitee
commit 3d2d6cafe3
2 changed files with 36 additions and 1 deletions

View File

@ -0,0 +1,31 @@
From a9e6a71f9435a50c582993e946be4d53828bb48d Mon Sep 17 00:00:00 2001
From: maminjie <maminjie1@huawei.com>
Date: Sat, 13 Mar 2021 16:03:03 +0800
Subject: [PATCH] Fix the invalid memory address or nil pointer reference
---
libpod/stats.go | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libpod/stats.go b/libpod/stats.go
index c58a461..97a2169 100644
--- a/libpod/stats.go
+++ b/libpod/stats.go
@@ -57,9 +57,11 @@ func (c *Container) GetContainerStats(previousStats *ContainerStats) (*Container
previousCPU := previousStats.CPUNano
previousSystem := previousStats.SystemNano
stats.CPU = calculateCPUPercent(cgroupStats, previousCPU, previousSystem)
- stats.MemUsage = cgroupStats.Memory.Usage.Usage
- stats.MemLimit = getMemLimit(cgroupStats.Memory.Usage.Limit)
- stats.MemPerc = (float64(stats.MemUsage) / float64(stats.MemLimit)) * 100
+ if cgroupStats.Memory != nil {
+ stats.MemUsage = cgroupStats.Memory.Usage.Usage
+ stats.MemLimit = getMemLimit(cgroupStats.Memory.Usage.Limit)
+ stats.MemPerc = (float64(stats.MemUsage) / float64(stats.MemLimit)) * 100
+ }
stats.PIDs = 0
if conState == ContainerStateRunning {
stats.PIDs = cgroupStats.Pids.Current
--
2.23.0

View File

@ -1,6 +1,6 @@
Name: podman
Version: 0.10.1
Release: 8
Release: 9
Summary: A daemonless container engine for managing Containers
Epoch: 1
License: ASL 2.0
@ -114,6 +114,7 @@ Patch2: CVE-2021-20188-PRE1.patch
Patch3: CVE-2021-20188-PRE2.patch
Patch4: CVE-2021-20188-PRE3.patch
Patch5: CVE-2021-20188.patch
Patch6: 0002-Fix-the-invalid-memory-address-reference.patch
%description
Podman manages the entire container ecosystem which includes pods,
@ -222,6 +223,9 @@ install -Dp -m644 libpod.conf %{buildroot}%{_datadir}/containers/libpod.conf
%{_mandir}/man5/*.5*
%changelog
* Sat Mar 13 2021 maminjie <maminjie1@huawei.com> - 1:0.10.1-9
- Fix the invalid memory address reference
* Wed Mar 3 2021 wangxiao <wangxiao65@huawei.com> - 1:0.10.1-8
- Fix CVE-2021-20188