gfs2-utils: master - gfs2_edit: Check more error values from gfs2_get_bitmap

Andrew Price andyp at fedoraproject.org
Wed Jan 11 18:39:52 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=7624e972957b02fd8bb1f7ea58c60afec3e925cc
Commit:        7624e972957b02fd8bb1f7ea58c60afec3e925cc
Parent:        1c42411b5a8f38deabdcb4d52139da580cd1a9a9
Author:        Andrew Price <anprice at redhat.com>
AuthorDate:    Mon Jan 9 04:28:08 2012 +0000
Committer:     Andrew Price <anprice at redhat.com>
CommitterDate: Wed Jan 11 18:17:56 2012 +0000

gfs2_edit: Check more error values from gfs2_get_bitmap

Spotted by coverity: gfs2_get_bitmap returns -1 on error and it was
being used as an array index in display_block_type. (2 remaining
occurrences.)

Signed-off-by: Andrew Price <anprice at redhat.com>
---
 gfs2/edit/hexedit.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 69d499e..808ebb1 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -697,8 +697,13 @@ int display_block_type(int from_restore)
 			if ((be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RG) ||
 			    (be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RB))
 				type = 4;
-			else
+			else {
 				type = gfs2_get_bitmap(&sbd, block, rgd);
+				if (type < 0) {
+					fprintf(stderr, "Failed to retrieve block state from bitmap\n");
+					exit(-1);
+				}
+			}
 		} else
 			type = 4;
 		screen_chunk_size = ((termlines - 4) * 16) >> 8 << 8;
@@ -724,6 +729,10 @@ int display_block_type(int from_restore)
 				print_gfs2(" blk ");
 				for (b = blknum; b < blknum + 4; b++) {
 					btype = gfs2_get_bitmap(&sbd, b, rgd);
+					if (btype < 0) {
+						fprintf(stderr, "Failed to retrieve block state from bitmap\n");
+						exit(-1);
+					}
 					print_gfs2("0x%x-%s  ", b,
 						   allocdesc[sbd.gfs1][btype]);
 				}


More information about the cluster-commits mailing list