* [PATCH] debugfs: fix encoding handling in dx_hash command
@ 2019-04-22 21:01 Eric Biggers
2019-04-23 4:07 ` Gabriel Krisman Bertazi
0 siblings, 1 reply; 3+ messages in thread
From: Eric Biggers @ 2019-04-22 21:01 UTC (permalink / raw)
To: linux-ext4; +Cc: Gabriel Krisman Bertazi
From: Eric Biggers <ebiggers@google.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@collabora.co.uk>
Signed-off-by: Eric Biggers <ebiggers@google.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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] debugfs: fix encoding handling in dx_hash command
2019-04-22 21:01 [PATCH] debugfs: fix encoding handling in dx_hash command Eric Biggers
@ 2019-04-23 4:07 ` Gabriel Krisman Bertazi
2019-04-29 0:20 ` Theodore Ts'o
0 siblings, 1 reply; 3+ messages in thread
From: Gabriel Krisman Bertazi @ 2019-04-23 4:07 UTC (permalink / raw)
To: Eric Biggers; +Cc: linux-ext4, Gabriel Krisman Bertazi
Eric Biggers <ebiggers@kernel.org> writes:
> From: Eric Biggers <ebiggers@google.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.
>
Ugly. Thanks for finding it.
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
--
Gabriel Krisman Bertazi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] debugfs: fix encoding handling in dx_hash command
2019-04-23 4:07 ` Gabriel Krisman Bertazi
@ 2019-04-29 0:20 ` Theodore Ts'o
0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2019-04-29 0:20 UTC (permalink / raw)
To: Gabriel Krisman Bertazi; +Cc: Eric Biggers, linux-ext4, Gabriel Krisman Bertazi
On Tue, Apr 23, 2019 at 12:07:12AM -0400, Gabriel Krisman Bertazi wrote:
> Eric Biggers <ebiggers@kernel.org> writes:
>
> > From: Eric Biggers <ebiggers@google.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.
> >
>
> Ugly. Thanks for finding it.
>
> Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-04-29 0:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-22 21:01 [PATCH] debugfs: fix encoding handling in dx_hash command Eric Biggers
2019-04-23 4:07 ` Gabriel Krisman Bertazi
2019-04-29 0:20 ` Theodore Ts'o
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).