From: R. Steve McKown Date: Fri, 28 Sep 2012 04:41:36 +0000 (-0600) Subject: Properly handle wrong arg count when -t X-Git-Tag: 0.4~1 X-Git-Url: https://oss.titaniummirror.com/gitweb?p=repo_shell.git;a=commitdiff_plain;h=ebbf97d1d30077057f22a808dfc4d02ce07ff338 Properly handle wrong arg count when -t --- diff --git a/repo_shell.c b/repo_shell.c index 4d9f79b..dc9b8d6 100644 --- a/repo_shell.c +++ b/repo_shell.c @@ -203,9 +203,12 @@ int main(int argc, char **argv) if (ini_parse(CFG_FILE, ini_handler, &cfg) < 0) die("cannot read config file %s", CFG_FILE); - if (argc == 4 && (!strcmp(argv[1], "-t") || - !strcmp(argv[1], "--test"))) { - perms_t p = git_acl(argv[2], argv[3], cfg.git_acl_file); + if ((!strcmp(argv[1], "-t") || !strcmp(argv[1], "--test"))) { + perms_t p; + + if (argc !=4) + die("usage: %s -t ", argv[0]); + p = git_acl(argv[2], argv[3], cfg.git_acl_file); fprintf(stderr, "user '%s' repo '%s' perms '%s'\n via userid '%s' repoid '%s'\n", argv[2], argv[3], git_acl_perms_as_str(p), git_acl_last_userid(),