summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2015-03-01 20:59:06 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2015-03-01 20:59:06 +0000
commit404a31368d3b3caf443650a19fbc33eb253a1d99 (patch)
tree96f8cca3e2a6b3580272d42c2b5ce2b59e7be590 /bin
parent22c7cbc33baca7cfc523422962f8217d7809e041 (diff)
Avoid SIGFPE when parsing an invalid ext2fs through a raw device operation.
ok millert
Diffstat (limited to 'bin')
-rw-r--r--bin/df/ext2fs_df.c7
1 files changed, 4 insertions, 3 deletions
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);