0003-Do-not-require-the-IANA-PEN-registry-file.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. From 26b088193a55624df4cbe2a0d33c7bba5bca108d Mon Sep 17 00:00:00 2001
  2. From: Vincent Fazio <vfazio@gmail.com>
  3. Date: Sat, 7 Jan 2023 21:02:48 -0600
  4. Subject: [PATCH] Do not require the IANA PEN registry file
  5. Previously, ipmitool would fail to run if the local copy of the IANA PEN
  6. registry could not be parsed.
  7. When the registry is not available the manufacturer will be "Unknown" but
  8. ipmitool will otherwise function so should not be considered fatal.
  9. Also, fix an issue with improperly handling the `oem_info_list_load`
  10. return value. Previously, in `ipmi_oem_info_init`, if `oem_info_list_load`
  11. returned a negative value due to the registry file not existing, an
  12. improper count would cause `oem_info_init_from_list` to aallocate a list
  13. that didn't encompass the full header/tail list.
  14. IANA PEN registry open failed: No such file or directory
  15. Allocating 3 entries
  16. [ 1] 16777214 | A Debug Assisting Company, Ltd.
  17. [ 0] 1048575 | Unspecified
  18. Now, use a signed int and ensure a valid count of loaded OEMs is used.
  19. Signed-off-by: Vincent Fazio <vfazio@gmail.com>
  20. [vfazio: backport from upstream 26b088193a55624df4cbe2a0d33c7bba5bca108d]
  21. Signed-off-by: Vincent Fazio <vfazio@gmail.com>
  22. ---
  23. include/ipmitool/ipmi_strings.h | 2 +-
  24. lib/ipmi_main.c | 5 +----
  25. lib/ipmi_strings.c | 19 +++++--------------
  26. 3 files changed, 7 insertions(+), 19 deletions(-)
  27. diff --git a/include/ipmitool/ipmi_strings.h b/include/ipmitool/ipmi_strings.h
  28. index 17c37c6..d60179c 100644
  29. --- a/include/ipmitool/ipmi_strings.h
  30. +++ b/include/ipmitool/ipmi_strings.h
  31. @@ -55,7 +55,7 @@ extern const struct valstr ipmi_integrity_algorithms[];
  32. extern const struct valstr ipmi_encryption_algorithms[];
  33. extern const struct valstr ipmi_user_enable_status_vals[];
  34. extern const struct valstr *ipmi_oem_info;
  35. -int ipmi_oem_info_init();
  36. +void ipmi_oem_info_init();
  37. void ipmi_oem_info_free();
  38. extern const struct valstr picmg_frucontrol_vals[];
  39. diff --git a/lib/ipmi_main.c b/lib/ipmi_main.c
  40. index a673a30..510bc2d 100644
  41. --- a/lib/ipmi_main.c
  42. +++ b/lib/ipmi_main.c
  43. @@ -853,10 +853,7 @@ ipmi_main(int argc, char ** argv,
  44. }
  45. /* load the IANA PEN registry */
  46. - if (ipmi_oem_info_init()) {
  47. - lprintf(LOG_ERR, "Failed to initialize the OEM info dictionary");
  48. - goto out_free;
  49. - }
  50. + ipmi_oem_info_init();
  51. /* run OEM setup if found */
  52. if (oemtype &&
  53. diff --git a/lib/ipmi_strings.c b/lib/ipmi_strings.c
  54. index 26b359f..c8fc2d0 100644
  55. --- a/lib/ipmi_strings.c
  56. +++ b/lib/ipmi_strings.c
  57. @@ -1719,39 +1719,30 @@ out:
  58. return rc;
  59. }
  60. -int ipmi_oem_info_init()
  61. +void ipmi_oem_info_init()
  62. {
  63. oem_valstr_list_t terminator = { { -1, NULL}, NULL }; /* Terminator */
  64. oem_valstr_list_t *oemlist = &terminator;
  65. bool free_strings = true;
  66. - size_t count;
  67. - int rc = -4;
  68. + int count;
  69. lprintf(LOG_INFO, "Loading IANA PEN Registry...");
  70. if (ipmi_oem_info) {
  71. lprintf(LOG_INFO, "IANA PEN Registry is already loaded");
  72. - rc = 0;
  73. goto out;
  74. }
  75. - if (!(count = oem_info_list_load(&oemlist))) {
  76. - /*
  77. - * We can't identify OEMs without a loaded registry.
  78. - * Set the pointer to dummy and return.
  79. - */
  80. - ipmi_oem_info = ipmi_oem_info_dummy;
  81. - goto out;
  82. + if ((count = oem_info_list_load(&oemlist)) < 1) {
  83. + lprintf(LOG_WARN, "Failed to load entries from IANA PEN Registry");
  84. + count = 0;
  85. }
  86. /* In the array was allocated, don't free the strings at cleanup */
  87. free_strings = !oem_info_init_from_list(oemlist, count);
  88. - rc = IPMI_CC_OK;
  89. -
  90. out:
  91. oem_info_list_free(&oemlist, free_strings);
  92. - return rc;
  93. }
  94. void ipmi_oem_info_free()
  95. --
  96. 2.25.1