1 Star 0 Fork 12

靳智敏/ipmitool

forked from src-openEuler/ipmitool 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
fru-fixup-array-bounds-checking.patch 2.08 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 10:53 . Package init
From 6d515dd06bcb89598465cc69e89e37684577e289 Mon Sep 17 00:00:00 2001
From: Patrick Venture <venture@google.com>
Date: Mon, 26 Nov 2018 12:38:04 -0800
Subject: [PATCH 098/119] fru: fixup array bounds checking
Fixup the following array bounds checking bugs:
[lib/ipmi_fru.c:1003]: (style) Array index 'i' is
used before limits check.
[lib/ipmi_fru.c:1127]: (style) Array index 'i' is
used before limits check.
[lib/ipmi_fru.c:1262]: (style) Array index 'i' is
used before limits check.
Signed-off-by: Patrick Venture <venture@google.com>
---
include/ipmitool/ipmi_fru.h | 2 ++
lib/ipmi_fru.c | 9 +++------
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/include/ipmitool/ipmi_fru.h b/include/ipmitool/ipmi_fru.h
index 65696ba..c543efc 100644
--- a/include/ipmitool/ipmi_fru.h
+++ b/include/ipmitool/ipmi_fru.h
@@ -41,6 +41,8 @@
# include <config.h>
#endif
+#define FRU_END_OF_FIELDS 0xc1
+
#define GET_FRU_INFO 0x10
#define GET_FRU_DATA 0x11
#define SET_FRU_DATA 0x12
diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c
index 6115ae6..5057dc3 100644
--- a/lib/ipmi_fru.c
+++ b/lib/ipmi_fru.c
@@ -957,8 +957,7 @@ fru_area_print_chassis(struct ipmi_intf * intf, struct fru_info * fru,
}
/* read any extra fields */
- while ((fru_data[i] != 0xc1) && (i < fru_len))
- {
+ while ((i < fru_len) && (fru_data[i] != FRU_END_OF_FIELDS)) {
int j = i;
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area != NULL) {
@@ -1083,8 +1082,7 @@ fru_area_print_board(struct ipmi_intf * intf, struct fru_info * fru,
}
/* read any extra fields */
- while ((fru_data[i] != 0xc1) && (i < fru_len))
- {
+ while ((i < fru_len) && (fru_data[i] != FRU_END_OF_FIELDS)) {
int j = i;
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area != NULL) {
@@ -1218,8 +1216,7 @@ fru_area_print_product(struct ipmi_intf * intf, struct fru_info * fru,
}
/* read any extra fields */
- while ((fru_data[i] != 0xc1) && (i < fru_len))
- {
+ while ((i < fru_len) && (fru_data[i] != FRU_END_OF_FIELDS)) {
int j = i;
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area != NULL) {
--
2.19.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jinzhimin369/ipmitool.git
git@gitee.com:jinzhimin369/ipmitool.git
jinzhimin369
ipmitool
ipmitool
master

搜索帮助