From owner-svn-src-all@freebsd.org Sat Feb 25 00:09:13 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6B242CEC5AE; Sat, 25 Feb 2017 00:09:13 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 395D8168F; Sat, 25 Feb 2017 00:09:13 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v1P09Cl9033061; Sat, 25 Feb 2017 00:09:12 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1P09CMq033060; Sat, 25 Feb 2017 00:09:12 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201702250009.v1P09CMq033060@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sat, 25 Feb 2017 00:09:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314229 - head/sbin/nvmecontrol X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Feb 2017 00:09:13 -0000 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]);