diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2022-01-01 20:11:31 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2022-01-01 20:17:32 +0000 |
| commit | 9f26b250bbc1d97f1093a0997bfd5ccc504a56b2 (patch) | |
| tree | 3515505991db93feacbcacd67de6fcddfae70cbb /main.c | |
| parent | doc: ctlseq: add missing ‘[‘ to a couple of CSI sequences (diff) | |
foot{,client}: handle argc == 0
Our getopt_long() based argument parser would (correctly) break out of
the while loop immediately. However, we would then proceed and
decrement ‘argc’ by 1, resulting in it being -1.
This was then passed to the terminal constructor, which passed it on
to the client application fork+exec logic. That finally resulted in an
exec(3) failure:
err: slave.c:339: SHELL=/bin/zsh: failed to execute: No such file or directory
err: fdm.c:215: no such FD: 7
info: main.c:604: goodbye
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -168,7 +168,7 @@ main(int argc, char *const *argv) * don't pass this on to programs launched by us */ unsetenv("DESKTOP_STARTUP_ID"); - const char *const prog_name = argv[0]; + const char *const prog_name = argc > 0 ? argv[0] : "<nullptr>"; static const struct option longopts[] = { {"config", required_argument, NULL, 'c'}, @@ -401,8 +401,10 @@ main(int argc, char *const *argv) as_server && log_syslog, (enum fcft_log_class)log_level); - argc -= optind; - argv += optind; + if (argc > 0) { + argc -= optind; + argv += optind; + } LOG_INFO("%s", version_and_features()); |
