Blame SOURCES/0013-lanplus-Cleanup.-Refix-6dec83ff-fix-be2c0c4b.patch

9e5419
From 646160e2175f9e0ba33e4f2bda12d84555e9c30e Mon Sep 17 00:00:00 2001
9e5419
From: Alexander Amelkin <alexander@amelkin.msk.ru>
9e5419
Date: Thu, 29 Nov 2018 13:10:53 +0300
9e5419
Subject: [PATCH] lanplus: Cleanup. Refix 6dec83ff, fix be2c0c4b
9e5419
9e5419
This is a cleanup commit.
9e5419
9e5419
Commit 6dec83ff removed assignment of `rsp` pointer
9e5419
in SOL-processing block of ipmi_lan_poll_single(),
9e5419
but left the check for the pointer validity in place.
9e5419
Although that has effectively fixed the bug of potentially
9e5419
accessing the null `rsp` pointer in the `else` block introduced
9e5419
with be2c0c4b, the resulting if/else looked suspicious and left
9e5419
and impression that a NULL pointer could still be accessed.
9e5419
9e5419
This commit removes the check for `rsp` from the `if`
9e5419
as it is checked at the start of the function where `rsp`
9e5419
is initialized (and that is the only place where it is ever changed).
9e5419
9e5419
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
9e5419
(cherry picked from commit 64727f59c4a1412fdb73e092fb838ae66e2aad1a)
9e5419
9e5419
lanplus: Fix segfault for truncated dcmi response
9e5419
9e5419
On occasion a dcmi power reading will return error C6, and a
9e5419
truncated response payload. As the decrypted payload is shorter
9e5419
than the expected length, lanplus_decrypt_aes_cbc_128() adjusts
9e5419
the payload_size downward by one byte. In ipmi_lan_poll_single()
9e5419
the calculation to determine if the payload size has increased
9e5419
erroniously sets extra_data_length to -1, with a subsequent
9e5419
segv when calling a memmove to shift response data.
9e5419
The fix is to check for a positive value in the extra_data_length.
9e5419
9e5419
Resolves ipmitool/ipmitool#72
9e5419
9e5419
(cherry picked from commit 9ec2232321a7bca7e1fb8f939d071f12c8dfa7fd)
9e5419
---
9e5419
 src/plugins/lanplus/lanplus.c | 4 ++--
9e5419
 1 file changed, 2 insertions(+), 2 deletions(-)
9e5419
9e5419
diff --git a/src/plugins/lanplus/lanplus.c b/src/plugins/lanplus/lanplus.c
9e5419
index c442c0e..ef132f6 100644
9e5419
--- a/src/plugins/lanplus/lanplus.c
9e5419
+++ b/src/plugins/lanplus/lanplus.c
9e5419
@@ -814,7 +814,7 @@ ipmi_lan_poll_single(struct ipmi_intf * intf)
9e5419
 			 * rsp->data_len becomes the length of that data
9e5419
 			 */
9e5419
 			extra_data_length = payload_size - (offset - payload_start) - 1;
9e5419
-			if (extra_data_length) {
9e5419
+			if (extra_data_length > 0) {
9e5419
 				rsp->data_len = extra_data_length;
9e5419
 				memmove(rsp->data, rsp->data + offset, extra_data_length);
9e5419
 			} else {
9e5419
@@ -868,7 +868,7 @@ ipmi_lan_poll_single(struct ipmi_intf * intf)
9e5419
 		}
9e5419
 		read_sol_packet(rsp, &offset);
9e5419
 		extra_data_length = payload_size - (offset - payload_start);
9e5419
-		if (rsp && extra_data_length) {
9e5419
+		if (extra_data_length > 0) {
9e5419
 			rsp->data_len = extra_data_length;
9e5419
 			memmove(rsp->data, rsp->data + offset, extra_data_length);
9e5419
 		} else {
9e5419
-- 
9e5419
2.26.3
9e5419