ipmid: Fix crash on scandir failure
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@ozlabs.org>
diff --git a/ipmid.C b/ipmid.C
index fbaf78c..0c7be7b 100644
--- a/ipmid.C
+++ b/ipmid.C
@@ -341,6 +341,9 @@
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;