40 lines
1007 B
Diff
40 lines
1007 B
Diff
From 6989c8413f80429b6c82d1fef4c8d0a79daf6d7b Mon Sep 17 00:00:00 2001
|
|
From: fengtao40 <fengtao40@huawei.com>
|
|
Date: Tue, 11 Feb 2020 21:05:31 -0500
|
|
Subject: [PATCH] Fix buffer overflow in ipmi_spd_print_fru
|
|
|
|
---
|
|
lib/dimm_spd.c | 9 ++++++++-
|
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
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)
|
|
}
|
|
|
|
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);
|
|
--
|
|
2.19.1
|
|
|