Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Feb 2017 00:09:12 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r314229 - head/sbin/nvmecontrol
Message-ID:  <201702250009.v1P09CMq033060@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Sat Feb 25 00:09:12 2017
New Revision: 314229
URL: https://svnweb.freebsd.org/changeset/base/314229

Log:
  Exit with usage if argv[1] is NULL in dispatch. This fixes core dumps
  when a command has subcommands, but the user doesn't give the
  parameters on the command line.
  
  Sponsored by: Netflix

Modified:
  head/sbin/nvmecontrol/nvmecontrol.c

Modified: head/sbin/nvmecontrol/nvmecontrol.c
==============================================================================
--- head/sbin/nvmecontrol/nvmecontrol.c	Sat Feb 25 00:09:02 2017	(r314228)
+++ head/sbin/nvmecontrol/nvmecontrol.c	Sat Feb 25 00:09:12 2017	(r314229)
@@ -75,6 +75,11 @@ dispatch(int argc, char *argv[], struct 
 {
 	struct nvme_function *f = tbl;
 
+	if (argv[1] == NULL) {
+		gen_usage(tbl);
+		return;
+	}
+
 	while (f->name != NULL) {
 		if (strcmp(argv[1], f->name) == 0)
 			f->fn(argc-1, &argv[1]);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201702250009.v1P09CMq033060>