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