aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox/0001-libbb-fix-time-parsing-of-CC-YY-MMDDhhmm-.SS.patch
blob: 3169bdff46d89bc45f23c6f204d6eda6a5e4b1a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From c9ee7417d8d838c16bc2c270d4dbb5fdb9c8b786 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 19 May 2016 16:17:32 +0200
Subject: [PATCH] libbb: fix time parsing of [[CC]YY]MMDDhhmm[.SS]

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

closes 8951

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 libbb/time.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libbb/time.c b/libbb/time.c
index aa19a47..82e6cb1 100644
--- a/libbb/time.c
+++ b/libbb/time.c
@@ -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",
-- 
2.8.2