From owner-svn-src-head@freebsd.org Tue Apr 26 10:04:07 2016 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 727DFB1C34D; Tue, 26 Apr 2016 10:04:07 +0000 (UTC) (envelope-from ed@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 2A18F1A50; Tue, 26 Apr 2016 10:04:07 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3QA46wr044465; Tue, 26 Apr 2016 10:04:06 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3QA46sY044464; Tue, 26 Apr 2016 10:04:06 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201604261004.u3QA46sY044464@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Tue, 26 Apr 2016 10:04:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298624 - head/usr.sbin/bsdinstall/partedit X-SVN-Group: head 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.21 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: Tue, 26 Apr 2016 10:04:07 -0000 Author: ed Date: Tue Apr 26 10:04:06 2016 New Revision: 298624 URL: https://svnweb.freebsd.org/changeset/base/298624 Log: Remove unportable calls to basename(). The POSIX version of basename() doesn't use a 'const char *' argument; the function may overwrite its input buffer. Instead of copying the input string, let's just simplify this code by using our getprogname() function that already returns the name of the application in the right format. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D6094 Modified: head/usr.sbin/bsdinstall/partedit/partedit.c Modified: head/usr.sbin/bsdinstall/partedit/partedit.c ============================================================================== --- head/usr.sbin/bsdinstall/partedit/partedit.c Tue Apr 26 07:47:01 2016 (r298623) +++ head/usr.sbin/bsdinstall/partedit/partedit.c Tue Apr 26 10:04:06 2016 (r298624) @@ -27,15 +27,15 @@ */ #include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include #include "diskeditor.h" #include "partedit.h" @@ -71,13 +71,14 @@ int main(int argc, const char **argv) { struct partition_metadata *md; - const char *prompt; + const char *progname, *prompt; struct partedit_item *items = NULL; struct gmesh mesh; int i, op, nitems, nscroll; int error; - if (strcmp(basename(argv[0]), "sade") == 0) + progname = getprogname(); + if (strcmp(progname, "sade") == 0) sade_mode = 1; TAILQ_INIT(&part_metadata); @@ -93,7 +94,7 @@ main(int argc, const char **argv) /* Revert changes on SIGINT */ signal(SIGINT, sigint_handler); - if (strcmp(basename(argv[0]), "autopart") == 0) { /* Guided */ + if (strcmp(progname, "autopart") == 0) { /* Guided */ prompt = "Please review the disk setup. When complete, press " "the Finish button."; /* Experimental ZFS autopartition support */ @@ -102,7 +103,7 @@ main(int argc, const char **argv) } else { part_wizard("ufs"); } - } else if (strcmp(basename(argv[0]), "scriptedpart") == 0) { + } else if (strcmp(progname, "scriptedpart") == 0) { error = scripted_editor(argc, argv); prompt = NULL; if (error != 0) {