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
This commit is contained in:
parent
49bebba7aa
commit
4e7e2cad09
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298624
@ -27,15 +27,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <libgen.h>
|
|
||||||
#include <libutil.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <fstab.h>
|
|
||||||
#include <libgeom.h>
|
|
||||||
#include <dialog.h>
|
#include <dialog.h>
|
||||||
#include <dlg_keys.h>
|
#include <dlg_keys.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fstab.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <libgeom.h>
|
||||||
|
#include <libutil.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "diskeditor.h"
|
#include "diskeditor.h"
|
||||||
#include "partedit.h"
|
#include "partedit.h"
|
||||||
@ -71,13 +71,14 @@ int
|
|||||||
main(int argc, const char **argv)
|
main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
struct partition_metadata *md;
|
struct partition_metadata *md;
|
||||||
const char *prompt;
|
const char *progname, *prompt;
|
||||||
struct partedit_item *items = NULL;
|
struct partedit_item *items = NULL;
|
||||||
struct gmesh mesh;
|
struct gmesh mesh;
|
||||||
int i, op, nitems, nscroll;
|
int i, op, nitems, nscroll;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (strcmp(basename(argv[0]), "sade") == 0)
|
progname = getprogname();
|
||||||
|
if (strcmp(progname, "sade") == 0)
|
||||||
sade_mode = 1;
|
sade_mode = 1;
|
||||||
|
|
||||||
TAILQ_INIT(&part_metadata);
|
TAILQ_INIT(&part_metadata);
|
||||||
@ -93,7 +94,7 @@ main(int argc, const char **argv)
|
|||||||
/* Revert changes on SIGINT */
|
/* Revert changes on SIGINT */
|
||||||
signal(SIGINT, sigint_handler);
|
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 "
|
prompt = "Please review the disk setup. When complete, press "
|
||||||
"the Finish button.";
|
"the Finish button.";
|
||||||
/* Experimental ZFS autopartition support */
|
/* Experimental ZFS autopartition support */
|
||||||
@ -102,7 +103,7 @@ main(int argc, const char **argv)
|
|||||||
} else {
|
} else {
|
||||||
part_wizard("ufs");
|
part_wizard("ufs");
|
||||||
}
|
}
|
||||||
} else if (strcmp(basename(argv[0]), "scriptedpart") == 0) {
|
} else if (strcmp(progname, "scriptedpart") == 0) {
|
||||||
error = scripted_editor(argc, argv);
|
error = scripted_editor(argc, argv);
|
||||||
prompt = NULL;
|
prompt = NULL;
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user