linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs_io: fix null pointer deref when complaining about scrub command
@ 2018-05-30  3:32 Darrick J. Wong
  2018-05-31 14:52 ` Eric Sandeen
  2018-05-31 14:55 ` Bill O'Donnell
  0 siblings, 2 replies; 3+ messages in thread
From: Darrick J. Wong @ 2018-05-30  3:32 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

Don't increment optind until we've validated that argv[optind] is a
valid scrub/repair subcommand and do not need to complain about
argv[optind].

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 io/scrub.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/io/scrub.c b/io/scrub.c
index 604daed9..37ffe46b 100644
--- a/io/scrub.c
+++ b/io/scrub.c
@@ -166,12 +166,11 @@ parse_args(
 			break;
 		}
 	}
-	optind++;
-
 	if (type < 0) {
 		printf(_("Unknown type '%s'.\n"), argv[optind]);
 		return command_usage(cmdinfo);
 	}
+	optind++;
 
 	switch (d->type) {
 	case ST_INODE:

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

end of thread, other threads:[~2018-05-31 14:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-30  3:32 [PATCH] xfs_io: fix null pointer deref when complaining about scrub command Darrick J. Wong
2018-05-31 14:52 ` Eric Sandeen
2018-05-31 14:55 ` Bill O'Donnell

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).