You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.6 KiB

  1. From 4f7778ed232a92bde388f38917b94f458a82c78e Mon Sep 17 00:00:00 2001
  2. From: Chrostoper Ertl <chertl@microsoft.com>
  3. Date: Thu, 28 Nov 2019 16:51:49 +0000
  4. Subject: [PATCH 08/11] session: Fix buffer overflow in ipmi_get_session_info
  5. Partial fix for CVE-2020-5208, see
  6. https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp
  7. The `ipmi_get_session_info` function does not properly check the
  8. response `data_len`, which is used as a copy size, allowing stack buffer
  9. overflow.
  10. ---
  11. lib/ipmi_session.c | 12 ++++++++----
  12. 1 file changed, 8 insertions(+), 4 deletions(-)
  13. diff --git a/lib/ipmi_session.c b/lib/ipmi_session.c
  14. index 141f0f4ec8dd..b9af1fd75d40 100644
  15. --- a/lib/ipmi_session.c
  16. +++ b/lib/ipmi_session.c
  17. @@ -309,8 +309,10 @@ ipmi_get_session_info(struct ipmi_intf * intf,
  18. }
  19. else
  20. {
  21. - memcpy(&session_info, rsp->data, rsp->data_len);
  22. - print_session_info(&session_info, rsp->data_len);
  23. + memcpy(&session_info, rsp->data,
  24. + __min(rsp->data_len, sizeof(session_info)));
  25. + print_session_info(&session_info,
  26. + __min(rsp->data_len, sizeof(session_info)));
  27. }
  28. break;
  29. @@ -341,8 +343,10 @@ ipmi_get_session_info(struct ipmi_intf * intf,
  30. break;
  31. }
  32. - memcpy(&session_info, rsp->data, rsp->data_len);
  33. - print_session_info(&session_info, rsp->data_len);
  34. + memcpy(&session_info, rsp->data,
  35. + __min(rsp->data_len, sizeof(session_info)));
  36. + print_session_info(&session_info,
  37. + __min(rsp->data_len, sizeof(session_info)));
  38. } while (i <= session_info.session_slot_count);
  39. break;
  40. --
  41. 2.27.0