libbb: fix time parsing of [[CC]YY]MMDDhhmm[.SS]. Closes 8951

If SS is not given a value, it is assumed to be zero.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Natanael Copa 2016-05-19 17:31:59 +02:00 committed by Denys Vlasenko
parent 8e95068c7f
commit b684d1b186

View File

@ -186,6 +186,7 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm)
} else {
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
}
ptm->tm_sec = 0; /* assume zero if [.SS] is not given */
if (end == '.') {
/* xxx.SS */
if (sscanf(strchr(date_str, '.') + 1, "%u%c",