Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Feb 2018 19:43:51 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r328724 - stable/11/sbin/nvmecontrol
Message-ID:  <201802011943.w11JhpLV031279@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Feb  1 19:43:51 2018
New Revision: 328724
URL: https://svnweb.freebsd.org/changeset/base/328724

Log:
  MFC r314229 (by imp):
  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.

Modified:
  stable/11/sbin/nvmecontrol/nvmecontrol.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/nvmecontrol/nvmecontrol.c
==============================================================================
--- stable/11/sbin/nvmecontrol/nvmecontrol.c	Thu Feb  1 19:43:18 2018	(r328723)
+++ stable/11/sbin/nvmecontrol/nvmecontrol.c	Thu Feb  1 19:43:51 2018	(r328724)
@@ -75,6 +75,11 @@ dispatch(int argc, char *argv[], struct nvme_function 
 {
 	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?201802011943.w11JhpLV031279>