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.

83 lines
2.8 KiB

  1. From e048e9c65a52f0879d482531e70735c1d314d43a Mon Sep 17 00:00:00 2001
  2. From: Chrostoper Ertl <chertl@microsoft.com>
  3. Date: Thu, 28 Nov 2019 17:06:39 +0000
  4. Subject: [PATCH 10/11] lanp: Fix buffer overflows in get_lan_param_select
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Partial fix for CVE-2020-5208, see
  9. https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp
  10. The `get_lan_param_select` function is missing a validation check on the
  11. response’s `data_len`, which it then returns to caller functions, where
  12. stack buffer overflow can occur.
  13. ---
  14. lib/ipmi_lanp.c | 14 +++++++-------
  15. 1 file changed, 7 insertions(+), 7 deletions(-)
  16. --- a/lib/ipmi_lanp.c
  17. +++ b/lib/ipmi_lanp.c
  18. @@ -1809,7 +1809,7 @@ ipmi_lan_alert_set(struct ipmi_intf * in
  19. if (p == NULL) {
  20. return (-1);
  21. }
  22. - memcpy(data, p->data, p->data_len);
  23. + memcpy(data, p->data, __min(p->data_len, sizeof(data)));
  24. /* set new ipaddr */
  25. memcpy(data+3, temp, 4);
  26. printf("Setting LAN Alert %d IP Address to %d.%d.%d.%d\n", alert,
  27. @@ -1824,7 +1824,7 @@ ipmi_lan_alert_set(struct ipmi_intf * in
  28. if (p == NULL) {
  29. return (-1);
  30. }
  31. - memcpy(data, p->data, p->data_len);
  32. + memcpy(data, p->data, __min(p->data_len, sizeof(data)));
  33. /* set new macaddr */
  34. memcpy(data+7, temp, 6);
  35. printf("Setting LAN Alert %d MAC Address to "
  36. @@ -1838,7 +1838,7 @@ ipmi_lan_alert_set(struct ipmi_intf * in
  37. if (p == NULL) {
  38. return (-1);
  39. }
  40. - memcpy(data, p->data, p->data_len);
  41. + memcpy(data, p->data, __min(p->data_len, sizeof(data)));
  42. if (strncasecmp(argv[1], "def", 3) == 0 ||
  43. strncasecmp(argv[1], "default", 7) == 0) {
  44. @@ -1864,7 +1864,7 @@ ipmi_lan_alert_set(struct ipmi_intf * in
  45. if (p == NULL) {
  46. return (-1);
  47. }
  48. - memcpy(data, p->data, p->data_len);
  49. + memcpy(data, p->data, __min(p->data_len, sizeof(data)));
  50. if (strncasecmp(argv[1], "on", 2) == 0 ||
  51. strncasecmp(argv[1], "yes", 3) == 0) {
  52. @@ -1889,7 +1889,7 @@ ipmi_lan_alert_set(struct ipmi_intf * in
  53. if (p == NULL) {
  54. return (-1);
  55. }
  56. - memcpy(data, p->data, p->data_len);
  57. + memcpy(data, p->data, __min(p->data_len, sizeof(data)));
  58. if (strncasecmp(argv[1], "pet", 3) == 0) {
  59. printf("Setting LAN Alert %d destination to PET Trap\n", alert);
  60. @@ -1917,7 +1917,7 @@ ipmi_lan_alert_set(struct ipmi_intf * in
  61. if (p == NULL) {
  62. return (-1);
  63. }
  64. - memcpy(data, p->data, p->data_len);
  65. + memcpy(data, p->data, __min(p->data_len, sizeof(data)));
  66. if (str2uchar(argv[1], &data[2]) != 0) {
  67. lprintf(LOG_ERR, "Invalid time: %s", argv[1]);
  68. @@ -1933,7 +1933,7 @@ ipmi_lan_alert_set(struct ipmi_intf * in
  69. if (p == NULL) {
  70. return (-1);
  71. }
  72. - memcpy(data, p->data, p->data_len);
  73. + memcpy(data, p->data, __min(p->data_len, sizeof(data)));
  74. if (str2uchar(argv[1], &data[3]) != 0) {
  75. lprintf(LOG_ERR, "Invalid retry: %s", argv[1]);