aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2021-01-13 06:21:53 -0600
committerRob Landley <rob@landley.net>2021-01-13 06:21:53 -0600
commite7c86f7d79f641ab8a0e542d32e857494e943389 (patch)
tree8bdb8d58ce8aaf6b7677a9087db83bb786c1a40a /toys/posix
parent661130b38cbf74056430e4b280512369dfcd9fe9 (diff)
downloadtoybox-e7c86f7d79f641ab8a0e542d32e857494e943389.tar.gz
Fix "date -I" segfault and teach lib/args.c that "I(opt):;" short opt with
no argument returns NULL same as --opt without =
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/date.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/toys/posix/date.c b/toys/posix/date.c
index ead72e15..86c2d343 100644
--- a/toys/posix/date.c
+++ b/toys/posix/date.c
@@ -138,7 +138,7 @@ void date_main(void)
if (FLAG(I)) {
char *iso_formats[] = {"%F","%FT%H%:z","%FT%R%:z","%FT%T%:z","%FT%T,%N%:z"};
- int i = stridx("dhmsn", *TT.I ? *TT.I : 'd');
+ int i = stridx("dhmsn", (TT.I && *TT.I) ? *TT.I : 'd');
if (i<0) help_exit("bad -I: %s", TT.I);
format_string = xstrdup(iso_formats[i]);