lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri, 9 Feb 2007 18:11:22 -0800
From:	"Brian D. Behlendorf" <behlendorf1@...l.gov>
To:	tytso@....edu
Cc:	linux-ext4@...r.kernel.org, adilger@...sterfs.com,
	behlendorf1@...l.gov, wartens2@...l.gov
Subject: e2fsprogs coverity patch <cid-25.diff>

Lawrence Livermore National Labs recently ran the source code
analysis tool Coverity over the e2fsprogs-1.39 source to see 
if it would identify any significant bugs.  The analysis
turned up 38 mostly minor issues which are enumerated here
with patches.  We went through and resolved these issues
but would love to see these mostly minor changes reviewed
and commited upstream.

Thanks,
Brian Behlendorf <behlendorf1@...l.gov>, and
Herb Wartens <wartens2@...l.gov>

-----------------------------------------------------------------------------
Coverity ID: 25: Resource Leak

Standardize the error handling in do_icheck() to have a single error
exit path which frees all locally allocated memory.  The only actual
leak here without this patch is the early return in the second hunk.

Index: e2fsprogs+chaos/debugfs/icheck.c
===================================================================
--- e2fsprogs+chaos.orig/debugfs/icheck.c
+++ e2fsprogs+chaos/debugfs/icheck.c
@@ -54,27 +54,27 @@ static int icheck_proc(ext2_filsys fs EX
 
 void do_icheck(int argc, char **argv)
 {
-	struct block_walk_struct bw;
+	struct block_walk_struct bw = { NULL, 0, 0, 0 };
 	struct block_info	*binfo;
 	int			i;
 	ext2_inode_scan		scan = 0;
 	ext2_ino_t		ino;
 	struct ext2_inode	inode;
 	errcode_t		retval;
-	char			*block_buf;
+	char			*block_buf = NULL;
 	
 	if (argc < 2) {
 		com_err(argv[0], 0, "Usage: icheck <block number> ...");
-		return;
+		goto error_out;
 	}
 	if (check_fs_open(argv[0]))
-		return;
+		goto error_out;
 
 	bw.barray = malloc(sizeof(struct block_info) * argc);
 	if (!bw.barray) {
 		com_err("icheck", ENOMEM,
 			"while allocating inode info array");
-		return;
+		goto error_out;
 	}
 	memset(bw.barray, 0, sizeof(struct block_info) * argc);
 
@@ -86,7 +86,7 @@ void do_icheck(int argc, char **argv)
 
 	for (i=1; i < argc; i++) {
 		if (strtoblk(argv[0], argv[i], &bw.barray[i-1].blk))
-			return;
+			goto error_out;
 	}
 
 	bw.num_blocks = bw.blocks_left = argc-1;
@@ -159,8 +159,10 @@ void do_icheck(int argc, char **argv)
 	}
 
 error_out:
-	free(bw.barray);
-	free(block_buf);
+	if (bw.barray)
+		free(bw.barray);
+	if (block_buf)
+		free(block_buf);
 	if (scan)
 		ext2fs_close_inode_scan(scan);
 	return;
-
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ