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

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