[Ocfs2-tools-devel] [PATCH] debugfs: segmentation fault caused by bad argument

Eric Ren zren at suse.com
Tue Jul 7 20:24:13 PDT 2015


When executing "stat -t" command without filespec, segmentation fault
happens. It is because do_stat() pass a NULL pointer to string_to_inode().
So check arguments again before that time.

Signed-off-by: Eric Ren <zren at suse.com>
Reviewed-by: Goldwyn Rodrigues <rgoldwyn at suse.com>
Reviewed-by: Gang He <ghe at suse.com>
---
 debugfs.ocfs2/commands.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
index 1b0b2d9..70444c9 100644
--- a/debugfs.ocfs2/commands.c
+++ b/debugfs.ocfs2/commands.c
@@ -1021,6 +1021,11 @@ static void do_stat(char **args)
 		index++;
 	}
 
+	if (!args[index]) {
+		fprintf(stderr, "%s\n", stat_usage);
+		return ;
+	}
+
 	ret = string_to_inode(gbls.fs, gbls.root_blkno, gbls.cwd_blkno,
 			      args[index], &blkno);
 	if (ret) {
-- 
2.1.2




More information about the Ocfs2-tools-devel mailing list