[PATCH phosphor-host-ipmid v2 4/4] ipmid: Fix crash on scandir failure

OpenBMC Patches patches at stwcx.xyz
Thu Oct 29 13:37:05 AEDT 2015


From: Jeremy Kerr <jk at ozlabs.org>

Curently, if I have no ipmi_lib_path, ipmid crashes:

  $ ./ipmid
  Registering handler:[/usr/lib/host-ipmid/H��dH�%(]
  ERROR opening [/usr/lib/host-ipmid/H��dH�%(]: /usr/lib/host-ipmid/H��dH�%(: cannot open shared object file: No such file or directory
  *** Error in `./ipmid': munmap_chunk(): invalid pointer: 0x0000000000401eb6 ***
  Aborted (core dumped)

We need to check for the error case of a scandir().

Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
---
 ipmid.C | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ipmid.C b/ipmid.C
index fbaf78c..0c7be7b 100644
--- a/ipmid.C
+++ b/ipmid.C
@@ -341,6 +341,9 @@ void ipmi_register_callback_handlers(const char* ipmi_lib_path)
         handler_fqdn += "/";
 
         num_handlers = scandir(ipmi_lib_path, &handler_list, handler_select, alphasort);
+	if (num_handlers < 0)
+		return;
+
         while(num_handlers--)
         {
             handler_fqdn = ipmi_lib_path;
-- 
2.6.0




More information about the openbmc mailing list