From 404a31368d3b3caf443650a19fbc33eb253a1d99 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Sun, 1 Mar 2015 20:59:06 +0000 Subject: Avoid SIGFPE when parsing an invalid ext2fs through a raw device operation. ok millert --- bin/df/ext2fs_df.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/df/ext2fs_df.c b/bin/df/ext2fs_df.c index 07e02832ca3..47b99469c78 100644 --- a/bin/df/ext2fs_df.c +++ b/bin/df/ext2fs_df.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_df.c,v 1.12 2015/01/16 06:39:31 deraadt Exp $ */ +/* $OpenBSD: ext2fs_df.c,v 1.13 2015/03/01 20:59:05 tobias Exp $ */ /* * This file is substantially derived from src/sys/ufs/ext2fs/ext2fs_vfsops.c:e2fs_statfs(). @@ -77,8 +77,9 @@ e2fs_df(int rfd, char *file, struct statfs *sfsp) sfsp->f_bsize = 1024 << sblock.e2fs_log_bsize; sfsp->f_iosize = 1024 << sblock.e2fs_log_bsize; - ipb = sfsp->f_bsize / sizeof(struct ext2fs_dinode); - itpg = sblock.e2fs_ipg/ipb; + if ((ipb = sfsp->f_bsize / sizeof(struct ext2fs_dinode)) == 0) + return (-1); + itpg = sblock.e2fs_ipg / ipb; ncg = howmany(sblock.e2fs_bcount - sblock.e2fs_first_dblock, sblock.e2fs_bpg); -- cgit v1.2.3