diff options
author | Rob Landley <rob@landley.net> | 2015-08-11 01:50:19 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-08-11 01:50:19 -0500 |
commit | 7f6bb3dae7ffe5ffdf10cc2e73a803ff820ebca8 (patch) | |
tree | aca998074bcd8b985945d359b514c10c6a9d693c | |
parent | 0fb465194789965b6fb2efd31995a2441144d650 (diff) | |
download | toybox-7f6bb3dae7ffe5ffdf10cc2e73a803ff820ebca8.tar.gz toybox-7f6bb3dae7ffe5ffdf10cc2e73a803ff820ebca8.tar.bz2 toybox-7f6bb3dae7ffe5ffdf10cc2e73a803ff820ebca8.zip |
Bugfixes from Elliott Hughes: debug code got checked in (oops) and
uninitialized trash in struct tm fields could segfault glibc's strftime().
-rw-r--r-- | toys/posix/date.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/toys/posix/date.c b/toys/posix/date.c index 5719fd2..909ca5a 100644 --- a/toys/posix/date.c +++ b/toys/posix/date.c @@ -92,6 +92,8 @@ static int parse_default(char *str, struct tm *tm) { int len = 0; + memset(tm, 0, sizeof(struct tm)); + // Parse @UNIXTIME[.FRACTION] if (*str == '@') { long long ll; @@ -160,7 +162,6 @@ void date_main(void) if (toys.optflags & FLAG_u) utzset(); if (TT.showdate) { - setdate = TT.showdate; if (TT.setfmt) { char *s = strptime(TT.showdate, TT.setfmt+(*TT.setfmt=='+'), &tm); @@ -179,7 +180,6 @@ void date_main(void) ((toys.optflags & FLAG_u) ? gmtime_r : localtime_r)(&now, &tm); } - setdate = *toys.optargs; // Fall through if no arguments if (!setdate); // Display the date? @@ -202,7 +202,6 @@ void date_main(void) if (tv.tv_sec == (time_t)-1) goto bad_date; tv.tv_usec = TT.nano/1000; -exit(1); if (settimeofday(&tv, NULL) < 0) perror_msg("cannot set date"); } |