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>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 22 Apr 2019 14:01:23 -0700
From:   Eric Biggers <ebiggers@...nel.org>
To:     linux-ext4@...r.kernel.org
Cc:     Gabriel Krisman Bertazi <krisman@...labora.co.uk>
Subject: [PATCH] debugfs: fix encoding handling in dx_hash command

From: Eric Biggers <ebiggers@...gle.com>

Fix the following bugs:

1. 'encoding' and 'hash_flags' are not initialized, causing a segfault.

2. 'hash_flags' incorrectly uses a __bitwise type.

3. The optstring doesn't contain "c" or "e", so the -c and -e options
   aren't recognized.

4. The code that handles the -e option always returns.

Fixes: ef733f1a97ec ("debugfs: support encoding when printing the file hash")
Cc: Gabriel Krisman Bertazi <krisman@...labora.co.uk>
Signed-off-by: Eric Biggers <ebiggers@...gle.com>
---
 debugfs/htree.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/debugfs/htree.c b/debugfs/htree.c
index 1cdb3c6a..82406d4f 100644
--- a/debugfs/htree.c
+++ b/debugfs/htree.c
@@ -310,17 +310,18 @@ errout:
 void do_dx_hash(int argc, char *argv[], int sci_idx EXT2FS_ATTR((unused)),
 		void *infop EXT2FS_ATTR((unused)))
 {
-	ext2_dirhash_t hash, minor_hash, hash_flags;
+	ext2_dirhash_t hash, minor_hash;
 	errcode_t	err;
 	int		c;
 	int		hash_version = 0;
 	__u32		hash_seed[4];
-	const struct nls_table *encoding;
+	int		hash_flags = 0;
+	const struct nls_table *encoding = NULL;
 
 	hash_seed[0] = hash_seed[1] = hash_seed[2] = hash_seed[3] = 0;
 
 	reset_getopt();
-	while ((c = getopt (argc, argv, "h:s:")) != EOF) {
+	while ((c = getopt(argc, argv, "h:s:ce:")) != EOF) {
 		switch (c) {
 		case 'h':
 			hash_version = e2p_string2hash(optarg);
@@ -335,14 +336,16 @@ void do_dx_hash(int argc, char *argv[], int sci_idx EXT2FS_ATTR((unused)),
 			}
 			break;
 		case 'c':
-			hash_flags = EXT4_CASEFOLD_FL;
+			hash_flags |= EXT4_CASEFOLD_FL;
 			break;
 		case 'e':
 			encoding = nls_load_table(e2p_str2encoding(optarg));
-			if (!encoding)
+			if (!encoding) {
 				fprintf(stderr, "Invalid encoding: %s\n",
 					optarg);
 				return;
+			}
+			break;
 		default:
 			goto print_usage;
 		}
-- 
2.21.0.593.g511ec345e18-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ