gfs2-utils: master - gfs2_edit: Fix null pointer dereference in dump_journal

Andrew Price andyp at fedoraproject.org
Fri Jan 6 15:27:34 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=2e46fea08029eb744bf0964c3aa32da83aa3065a
Commit:        2e46fea08029eb744bf0964c3aa32da83aa3065a
Parent:        2e4fd21aeba5030a4ffb24ea4d52259e9e78755c
Author:        Andrew Price <anprice at redhat.com>
AuthorDate:    Fri Jan 6 13:04:19 2012 +0000
Committer:     Andrew Price <anprice at redhat.com>
CommitterDate: Fri Jan 6 13:04:19 2012 +0000

gfs2_edit: Fix null pointer dereference in dump_journal

Spotted by coverity: Dereferencing a pointer that might be null "(void
*)jbuf" when calling "fsck_readi"

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

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index b05a7d6..7a17c04 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -2672,6 +2672,10 @@ static void dump_journal(const char *journal)
 		j_bh = bread(&sbd, jblock);
 		j_inode = inode_get(&sbd, j_bh);
 		jbuf = malloc(sbd.bsize);
+		if (jbuf == NULL) {
+			fprintf(stderr, "Out of memory\n");
+			exit(-1);
+		}
 	}
 
 	for (jb = 0; jb < j_size; jb += (sbd.gfs1 ? 1:sbd.bsize)) {


More information about the cluster-commits mailing list