[PATCH] Fixed NULL pointer dereference in fprintf used by 'lsof' command

Andreas Heinig andreas.heinig at cs.tu-dortmund.de
Wed May 15 13:14:28 UTC 2013


Hello,

I use IMFS as root file system. When I use the 'lsof' command my system
crashes. The crash is a result of a NULL-pointer dereference caused by
fprintf due to a NULL pointer parameter.

The parameter represents the device. In IMFS no device seems to be present
(which shall be OK, since IMFS is a mem-only FS).

The attached patch adds an extra check:

Regards
Andreas
---
 cpukit/libmisc/shell/main_lsof.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/libmisc/shell/main_lsof.c b/cpukit/libmisc/shell/main_lsof.c
index ed0c87c..2c6ece1 100644
--- a/cpukit/libmisc/shell/main_lsof.c
+++ b/cpukit/libmisc/shell/main_lsof.c
@@ -44,7 +44,7 @@ static void lsof(void)
       mt_entry->writeable ? 'W' : 'R',
       mt_entry->type,
       mt_entry->target,
-      mt_entry->dev,
+      mt_entry->dev == NULL ? "none" : mt_entry->dev,
       mt_entry->mt_fs_root,
       mt_entry->mt_fs_root->location.node_access
     );
-- 
1.8.1.2




More information about the devel mailing list