summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobias <tobias@openbsd.org>2015-03-01 20:59:05 +0000
committertobias <tobias@openbsd.org>2015-03-01 20:59:05 +0000
commit584ed9724bf63aa5162bbf0e6eb043ac40300c26 (patch)
treee333463f91688a83c6083a9f0d9c132b9a5f62d7
parentsvc_is_base function didn't catched all base daemons, apparently found (diff)
downloadwireguard-openbsd-584ed9724bf63aa5162bbf0e6eb043ac40300c26.tar.xz
wireguard-openbsd-584ed9724bf63aa5162bbf0e6eb043ac40300c26.zip
Avoid SIGFPE when parsing an invalid ext2fs through a raw device operation.
ok millert
-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);