Skip to contentSkip to conversation

xfs_io: fix null pointer deref when complaining about scrub command

PATCH In review Darrick J. Wong 3 participants 3 messages May 30, 2018 – May 31, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_io: fix null pointer deref when complaining about scrub command

From: Darrick J. Wong <[email protected]>

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

---
 io/scrub.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
io/scrub.c +1 -2
index 604daed9..37ffe46b 100644
@@ -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:
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

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

Quoted 22 lines
---
  io/scrub.c |    3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
io/scrub.c +1 -2
index 604daed9..37ffe46b 100644
@@ -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:
Reviewed-by on v1 1/1
#2 lore raw
In reply to Darrick J. Wong
Quoted 7 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

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

Quoted 26 lines
---
 io/scrub.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
io/scrub.c +1 -3
index 604daed9..37ffe46b 100644
@@ -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:
--

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html