1 Star 0 Fork 12

streamlet_hy/ipmitool-oe

forked from src-openEuler/ipmitool 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-fru-Fix-crashes-on-6-bit-ASCII-strings.patch 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
From 1245aaa387dca1cb99408869b2c1b3e2410a1352 Mon Sep 17 00:00:00 2001
From: Alexander Amelkin <alexander@amelkin.msk.ru>
Date: Tue, 15 Sep 2020 16:49:20 +0300
Subject: [PATCH] fru: Fix crashes on 6-bit ASCII strings
Fix calculation of the buffer size for decoded 6-bit ASCII
strings. Previously the program could allocate too a short buffer
that caused buffer overflows and segmentation fault crashes on
certain FRU contents.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
---
lib/ipmi_fru.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c
index 501ef26..3d1d8a1 100644
--- a/lib/ipmi_fru.c
+++ b/lib/ipmi_fru.c
@@ -175,8 +175,8 @@ char * get_fru_area_str(uint8_t * data, uint32_t * offset)
size = (len * 2);
break;
case 2: /* 10b: 6-bit ASCII */
- /* 4 chars per group of 1-3 bytes */
- size = (((len * 4 + 2) / 3) & ~3);
+ /* 4 chars per group of 1-3 bytes, round up to 4 bytes boundary */
+ size = (len / 3 + 1) * 4;
break;
case 3: /* 11b: 8-bit ASCII */
/* no length adjustment */
--
2.20.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/streamlet_hy/ipmitool.git
git@gitee.com:streamlet_hy/ipmitool.git
streamlet_hy
ipmitool
ipmitool-oe
master

搜索帮助