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

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