Fix array index out-of-bounds

This commit is contained in:
luochenglcs 2022-09-01 14:21:09 +08:00
parent c213a99dcc
commit 6d3e2b9d38
2 changed files with 30 additions and 1 deletions

View File

@ -0,0 +1,25 @@
From ade9632aecbe1ed2d9a9220edcd42f56b9ad0eea Mon Sep 17 00:00:00 2001
From: luochenglcs <luochunsheng@huawei.com>
Date: Tue, 30 Aug 2022 15:47:39 +0800
Subject: [PATCH] avoid array index out-of-bounds
---
numad.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/numad.c b/numad.c
index 0721af4..58a198c 100644
--- a/numad.c
+++ b/numad.c
@@ -1983,6 +1983,8 @@ id_list_p pick_numa_nodes(int pid, int cpus, int mbs, int assume_enough_cpus) {
// Next line optional, since we will not look at that node again
tmp_node[index[best_node_ix]].magnitude = combined_value_of_weighted_resources(0, mbs, cpus, tmp_node[index[best_node_ix]].MBs_free, tmp_node[index[best_node_ix]].CPUs_free);
best_node_ix += 1;
+ if (best_node_ix >= num_nodes)
+ break;
}
// For existing processes, calculate the non-local memory percent to see if
// process is already in the right place.
--
1.8.3.1

View File

@ -1,6 +1,6 @@
Name: numad
Version: 0.5
Release: 31
Release: 32
Summary: NUMA user daemon
License: LGPLv2
URL: https://pagure.io/numad
@ -12,6 +12,7 @@ Requires(post): systemd-units
Requires(preun): systemd-units
Patch0: numad-0.5git-m-option.patch
Patch1: avoid-array-index-out-of-bounds.patch
%description
Numad is a deamon that monitors NUMA topology and usage and distributes
@ -55,6 +56,9 @@ install -m 644 numad.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
%systemd_postun numad.service
%changelog
* Thu Sep 1 2022 Chunsheng Luo<luochunsheng@huawei.com> - 0.5-32
- Fix array index out-of-bounds
* Fri Dec 20 2019 openEuler Buildteam <buildteam@openeuler.org> - 0.5-31
- Add missing post/pre requires