cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 1/8] gfs2_edit: Check more error values from gfs2_get_bitmap
@ 2012-01-11 18:21 Andrew Price
  2012-01-11 18:21 ` [Cluster-devel] [PATCH 2/8] gfs2_edit: Fix another resource leak in display_extended Andrew Price
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Andrew Price @ 2012-01-11 18:21 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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@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]);
 				}
-- 
1.7.6.5



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-01-11 18:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-11 18:21 [Cluster-devel] [PATCH 1/8] gfs2_edit: Check more error values from gfs2_get_bitmap Andrew Price
2012-01-11 18:21 ` [Cluster-devel] [PATCH 2/8] gfs2_edit: Fix another resource leak in display_extended Andrew Price
2012-01-11 18:21 ` [Cluster-devel] [PATCH 3/8] mkfs.gfs2: Fix use of uninitialized value in check_dev_content Andrew Price
2012-01-11 18:21 ` [Cluster-devel] [PATCH 4/8] gfs2_convert: Fix null pointer deref in journ_space_to_rg Andrew Price
2012-01-11 18:21 ` [Cluster-devel] [PATCH 5/8] gfs2_convert: Fix null pointer deref in conv_build_jindex Andrew Price
2012-01-11 18:21 ` [Cluster-devel] [PATCH 6/8] fsck.gfs2: Remove unsigned comparisons with zero Andrew Price
2012-01-11 18:21 ` [Cluster-devel] [PATCH 7/8] fsck.gfs2: Plug a leak in init_system_inodes() Andrew Price
2012-01-11 18:21 ` [Cluster-devel] [PATCH 8/8] libgfs2: Set errno in dirent_alloc and use dir_add consistently Andrew Price
2012-01-11 18:28   ` Bob Peterson
2012-01-11 18:43   ` Abhijith Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).