diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-07-22 10:00:40 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-07-22 09:08:09 +0000 |
| commit | e88f2331e7b7b97da8f178078031064a8c57a34f (patch) | |
| tree | ff4ba8365400c167732fedb526973d8290014cab /executor/executor.cc | |
| parent | df655b64ffc2879b80e652329fb7a11508e50310 (diff) | |
executor: refactor argument parsing
Check that we have at least command argument in the beginning.
Diffstat (limited to 'executor/executor.cc')
| -rw-r--r-- | executor/executor.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/executor/executor.cc b/executor/executor.cc index 5855ef9b4..3a1ce78bd 100644 --- a/executor/executor.cc +++ b/executor/executor.cc @@ -508,11 +508,15 @@ static uint64 sandbox_arg = 0; int main(int argc, char** argv) { - if (argc >= 2 && strcmp(argv[1], "runner") == 0) { + if (argc == 1) { + fprintf(stderr, "no command"); + return 1; + } + if (strcmp(argv[1], "runner") == 0) { runner(argv, argc); fail("runner returned"); } - if (argc >= 2 && strcmp(argv[1], "leak") == 0) { + if (strcmp(argv[1], "leak") == 0) { #if SYZ_HAVE_LEAK_CHECK check_leaks(argv + 2, argc - 2); #else @@ -520,10 +524,10 @@ int main(int argc, char** argv) #endif return 0; } - if (argc >= 2 && strcmp(argv[1], "test") == 0) + if (strcmp(argv[1], "test") == 0) return run_tests(argc == 3 ? argv[2] : nullptr); - if (argc < 2 || strcmp(argv[1], "exec") != 0) { + if (strcmp(argv[1], "exec") != 0) { fprintf(stderr, "unknown command"); return 1; } |
