Patchwork [07/25] e2fsck: handle null fs in print_pathname()

login
register
mail settings
Submitter Eric Sandeen
Date Sept. 16, 2011, 8:49 p.m.
Message ID <1316206180-6375-8-git-send-email-sandeen@redhat.com>
Download mbox | patch
Permalink /patch/115056/
State Accepted
Headers show

Comments

Eric Sandeen - Sept. 16, 2011, 8:49 p.m.
testing fs for NULL in expand_percent_expression():

	e2fsck_ctx = fs ? (e2fsck_t) fs->priv_data : NULL;

implies that fs could be NULL, but it's passed to print_pathname()
which defererences it without further testing.

So make this safe by returning "???" for a nul fs.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 e2fsck/message.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Theodore Ts'o - Sept. 16, 2011, 10:53 p.m.
On Fri, Sep 16, 2011 at 03:49:22PM -0500, Eric Sandeen wrote:
> testing fs for NULL in expand_percent_expression():
> 
> 	e2fsck_ctx = fs ? (e2fsck_t) fs->priv_data : NULL;
> 
> implies that fs could be NULL, but it's passed to print_pathname()
> which defererences it without further testing.
> 
> So make this safe by returning "???" for a nul fs.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Applied, thanks.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/e2fsck/message.c b/e2fsck/message.c
index 565c3cd..f178321 100644
--- a/e2fsck/message.c
+++ b/e2fsck/message.c
@@ -203,8 +203,9 @@  static void print_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino)
 		return;
 	}
 
-	retval = ext2fs_get_pathname(fs, dir, ino, &path);
-	if (retval)
+	if (fs)
+		retval = ext2fs_get_pathname(fs, dir, ino, &path);
+	if (!fs || retval)
 		fputs("???", stdout);
 	else {
 		safe_print(path, -1);