!167 add boundary check for settings

From: @luckky7 
Reviewed-by: @lvying6 
Signed-off-by: @lvying6
This commit is contained in:
openeuler-ci-bot 2024-11-06 06:42:42 +00:00 committed by Gitee
commit 46c433f91a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,39 @@
From abf36bf0351efde388c089245aed9f6d8d2e6d3b Mon Sep 17 00:00:00 2001
From: luckky <guodashun1@huawei.com>
Date: Wed, 6 Nov 2024 11:42:53 +0800
Subject: [PATCH] add boundary check for settings
1. add two boundary checks for page_isolation_threshold and hbm_online_repair_log_level
(0 <= page_isolation_threshold)
(0(LOG_DEBUG) <= hbm_online_repair_log_level <= 3(LOG_ERROR))
---
src/c/hbm_online_repair/hbm_online_repair.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/c/hbm_online_repair/hbm_online_repair.c b/src/c/hbm_online_repair/hbm_online_repair.c
index 943f201..00c9c0b 100644
--- a/src/c/hbm_online_repair/hbm_online_repair.c
+++ b/src/c/hbm_online_repair/hbm_online_repair.c
@@ -89,6 +89,9 @@ void hbm_param_init(void)
if (ret < 0) {
global_level_setting = DEFAULT_LOG_LEVEL;
log(LOG_WARNING, "Get log level from config failed, set the default value %d\n", DEFAULT_LOG_LEVEL);
+ } else if (global_level_setting < LOG_DEBUG || global_level_setting > LOG_ERROR) {
+ log(LOG_WARNING, "The log level value %d in config is out of range, set the default value %d\n", global_level_setting, DEFAULT_LOG_LEVEL);
+ global_level_setting = DEFAULT_LOG_LEVEL;
} else {
log(LOG_INFO, "log level: %d\n", global_level_setting);
}
@@ -98,6 +101,9 @@ void hbm_param_init(void)
if (ret < 0) {
page_isolation_threshold = DEFAULT_PAGE_ISOLATION_THRESHOLD;
log(LOG_WARNING, "Get page_isolation_threshold from config failed, set the default value %d\n", DEFAULT_PAGE_ISOLATION_THRESHOLD);
+ } else if (page_isolation_threshold < 0) {
+ log(LOG_WARNING, "The page_isolation_threshold %d in config is out of range, set the default value %d\n", page_isolation_threshold, DEFAULT_PAGE_ISOLATION_THRESHOLD);
+ page_isolation_threshold = DEFAULT_PAGE_ISOLATION_THRESHOLD;
} else {
log(LOG_INFO, "page_isolation_threshold: %d\n", page_isolation_threshold);
}
--
2.43.0

View File

@ -4,7 +4,7 @@
Summary: System Inspection Framework Summary: System Inspection Framework
Name: sysSentry Name: sysSentry
Version: 1.0.2 Version: 1.0.2
Release: 61 Release: 62
License: Mulan PSL v2 License: Mulan PSL v2
Group: System Environment/Daemons Group: System Environment/Daemons
Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz
@ -83,6 +83,7 @@ Patch70: ai_block_io-support-absolute-threshold-lower-limit.patch
Patch71: ai_block_io-fix-some-config-parameters-parse-bug.patch Patch71: ai_block_io-fix-some-config-parameters-parse-bug.patch
Patch72: update-nvme-config.patch Patch72: update-nvme-config.patch
Patch73: make-debug-msg-clear.patch Patch73: make-debug-msg-clear.patch
Patch74: add-boundary-check-for-settings.patch
BuildRequires: cmake gcc-c++ BuildRequires: cmake gcc-c++
BuildRequires: python3 python3-setuptools BuildRequires: python3 python3-setuptools
@ -376,6 +377,12 @@ rm -rf %{buildroot}
%attr(0550,root,root) %{python3_sitelib}/syssentry/bmc_alarm.py %attr(0550,root,root) %{python3_sitelib}/syssentry/bmc_alarm.py
%changelog %changelog
* Wed Nov 6 2024 luckky <guodashun1@huawei.com> - 1.0.2-62
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC: add boundary check for settings
* Tue Nov 5 2024 luckky <guodashun1@huawei.com> - 1.0.2-61 * Tue Nov 5 2024 luckky <guodashun1@huawei.com> - 1.0.2-61
- Type:bugfix - Type:bugfix
- CVE:NA - CVE:NA