From d08c2c074117f8171370a8d3e12f13a3e17d24f0 Mon Sep 17 00:00:00 2001 From: jozan Date: Sun, 15 Nov 2020 16:24:21 +0000 Subject: A directory is now a required argument, for safety FossilOrigin-Name: ff2d65680f254c7930990b40e3988f9b0443cd5dd58e852e5b13e0989de4d206 --- src/c_opts.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/c_opts.c') diff --git a/src/c_opts.c b/src/c_opts.c index 6df0722..996643e 100644 --- a/src/c_opts.c +++ b/src/c_opts.c @@ -190,7 +190,7 @@ c_get_opts C_C_OPT_FMT, optarg ); - exit(2); + exit(1); } else { opts->cxx = optarg[0] - 48; @@ -201,20 +201,25 @@ c_get_opts exit(1); } } + if ( + argv[0][0] != C_RECURSIVE_CHAR && + argv[optind] == NULL + ) { + c_dump_usage(); + exit(1); + } if ( argv[0][0] != C_RECURSIVE_CHAR && optind < argc && argv[optind] != NULL - ) { + ) { strncpy(opts->dir, argv[optind], PATH_MAX); if (opts->dir[strlen(opts->dir) - 1] == '/') { opts->dir[strlen(opts->dir) - 1] = 0x00; } } - else if (argv[0][0] == C_RECURSIVE_CHAR || argv[optind] == NULL) { + else if (argv[0][0] == C_RECURSIVE_CHAR) { strlcpy(opts->dir, ".", 2 * sizeof(char)); - } - if (argv[0][0] == C_RECURSIVE_CHAR) { c_recursive_parse(opts, argv); } ret = TRUE; -- cgit v1.2.3