ipmitool/ipmitool-CVE-2020-5208-Fix-buffer-overflow-in-ipmi_spd_print_fru.patch

40 lines
1007 B
Diff
Raw Normal View History

2020-03-13 22:06:06 +08:00
From 6989c8413f80429b6c82d1fef4c8d0a79daf6d7b Mon Sep 17 00:00:00 2001
2020-03-13 21:19:20 +08:00
From: fengtao40 <fengtao40@huawei.com>
2020-03-13 22:06:06 +08:00
Date: Tue, 11 Feb 2020 21:05:31 -0500
Subject: [PATCH] Fix buffer overflow in ipmi_spd_print_fru
2020-03-13 21:19:20 +08:00
---
2020-03-13 22:06:06 +08:00
lib/dimm_spd.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
2020-03-13 21:19:20 +08:00
2020-03-13 22:06:06 +08:00
diff --git a/lib/dimm_spd.c b/lib/dimm_spd.c
index 41e30db..68f3b4f 100644
--- a/lib/dimm_spd.c
+++ b/lib/dimm_spd.c
@@ -1621,7 +1621,7 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id)
struct ipmi_rq req;
struct fru_info fru;
uint8_t *spd_data, msg_data[4];
- int len, offset;
+ uint32_t len, offset;
msg_data[0] = id;
@@ -1697,6 +1697,13 @@ ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id)
2020-03-13 21:19:20 +08:00
}
2020-03-13 22:06:06 +08:00
len = rsp->data[0];
+ if(rsp->data_len < 1
+ || len > rsp->data_len - 1
+ || len > fru.size - offset)
+ {
+ printf(" Not enough buffer size");
+ return -1;
+ }
memcpy(&spd_data[offset], rsp->data + 1, len);
offset += len;
} while (offset < fru.size);
2020-03-13 21:19:20 +08:00
--
2.19.1