gfs2-utils: master - gfs2_edit: Fix divide by zero bug

Andrew Price andyp at fedoraproject.org
Wed Apr 17 15:37:04 UTC 2013


Gitweb:        http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=4d4c96cbb24a58b54a198e01044e7cce161ea323
Commit:        4d4c96cbb24a58b54a198e01044e7cce161ea323
Parent:        6649ab418b25992eb707ab821f2fdcb317c27dd9
Author:        Andrew Price <anprice at redhat.com>
AuthorDate:    Wed Apr 17 16:28:58 2013 +0100
Committer:     Andrew Price <anprice at redhat.com>
CommitterDate: Wed Apr 17 16:28:58 2013 +0100

gfs2_edit: Fix divide by zero bug

gfs2_edit uses its own superblock reading functions instead of read_sb
so the sd_blocks_per_bitmap 'constant' doesn't get calculated causing a
divide-by-zero crash. With this patch, the value is now calculated in
compute_constants() which does get called by gfs2_edit.

Signed-off-by: Andrew Price <anprice at redhat.com>
---
 gfs2/libgfs2/misc.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index 9efddcd..c05a770 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -70,6 +70,8 @@ int compute_constants(struct gfs2_sbd *sdp)
 	sdp->sd_hash_bsize = sdp->bsize / 2;
 	sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1;
 	sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64_t);
+	sdp->sd_blocks_per_bitmap = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header))
+	                             * GFS2_NBBY;
 
 	/*  Compute maximum reservation required to add a entry to a directory  */
 


More information about the cluster-commits mailing list