From owner-svn-src-head@freebsd.org Sat Dec 9 07:43:56 2017 Return-Path: Delivered-To: svn-src-head@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 B35F1E81E08; Sat, 9 Dec 2017 07:43:56 +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 6F5547B114; Sat, 9 Dec 2017 07:43:56 +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 vB97htcr093184; Sat, 9 Dec 2017 07:43:55 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vB97htAI093183; Sat, 9 Dec 2017 07:43:55 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201712090743.vB97htAI093183@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sat, 9 Dec 2017 07:43:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326727 - head/usr.sbin/efibootmgr X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/usr.sbin/efibootmgr X-SVN-Commit-Revision: 326727 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Dec 2017 07:43:56 -0000 Author: imp Date: Sat Dec 9 07:43:55 2017 New Revision: 326727 URL: https://svnweb.freebsd.org/changeset/base/326727 Log: Remove vestiges of -d and -p commands. Fix two core dumps when optional data isn't specified. Sponsored by: Netflix Modified: head/usr.sbin/efibootmgr/efibootmgr.c Modified: head/usr.sbin/efibootmgr/efibootmgr.c ============================================================================== --- head/usr.sbin/efibootmgr/efibootmgr.c Sat Dec 9 06:57:19 2017 (r326726) +++ head/usr.sbin/efibootmgr/efibootmgr.c Sat Dec 9 07:43:55 2017 (r326727) @@ -69,7 +69,6 @@ __FBSDID("$FreeBSD$"); #define BAD_LENGTH ((size_t)-1) typedef struct _bmgr_opts { - char *dev; char *env; char *loader; char *label; @@ -84,7 +83,6 @@ typedef struct _bmgr_opts { bool del_timeout; bool dry_run; bool once; - int part; int cp_src; bool set_active; bool set_bootnext; @@ -194,7 +192,7 @@ parse_args(int argc, char *argv[]) { int ch; - while ((ch = getopt_long(argc, argv, "A:a:B:C:cDd:e:hk:L:l:Nn:Oo:p:Tt:v", + while ((ch = getopt_long(argc, argv, "A:a:B:C:cDe:hk:L:l:Nn:Oo:Tt:v", lopts, NULL)) != -1) { switch (ch) { case 'A': @@ -218,9 +216,6 @@ parse_args(int argc, char *argv[]) case 'D': /* should be remove dups XXX */ opts.dry_run = true; break; - case 'd': - opts.dev = optarg; - break; case 'e': opts.env = strdup(optarg); break; @@ -251,9 +246,6 @@ parse_args(int argc, char *argv[]) case 'o': opts.order = strdup(optarg); break; - case 'p': - opts.part = strtoul(optarg, NULL, 10); - break; case 'T': opts.del_timeout = true; break; @@ -267,7 +259,7 @@ parse_args(int argc, char *argv[]) } } if (opts.create) { - if (!(opts.loader && opts.dev && opts.part)) + if (!opts.loader) errx(1, "%s",CREATE_USAGE); return; } @@ -598,7 +590,12 @@ create_loadopt(uint8_t *buf, size_t bufmax, uint32_t a /* * Compute the length to make sure the passed in buffer is long enough. */ - utf8_to_ucs2(description, &bbuf, &desc_len); + if (description) + utf8_to_ucs2(description, &bbuf, &desc_len); + else { + desc_len = 0; + bbuf = NULL; + } len = sizeof(uint32_t) + sizeof(uint16_t) + desc_len + dp_size + optional_data_size; if (len > bufmax) { free(bbuf); @@ -665,7 +662,7 @@ make_boot_var(const char *label, const char *loader, c err(1, "malloc"); lopt_size = create_loadopt(load_opt_buf, MAX_LOADOPT_LEN, load_attrs, - dp, llen + klen, label, env, strlen(env) + 1); + dp, llen + klen, label, env, env ? strlen(env) + 1 : 0); if (lopt_size == BAD_LENGTH) errx(1, "Can't crate loadopt");