aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorDavis Mosenkovs <davikovs@gmail.com>2016-04-20 14:44:13 -0700
committerRob Landley <rob@landley.net>2016-04-21 17:16:13 -0500
commit00385e8d0e1f83a58710ada4a210d15102542b7d (patch)
tree201971a9221151d20a1f1224fb480f32effff1ed /toys
parent7b6957fa1e23f1b0f614bb5102c527bee2db3002 (diff)
downloadtoybox-00385e8d0e1f83a58710ada4a210d15102542b7d.tar.gz
Fix touch -t seconds parsing
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/touch.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/toys/posix/touch.c b/toys/posix/touch.c
index 052448ba..22a1e2e8 100644
--- a/toys/posix/touch.c
+++ b/toys/posix/touch.c
@@ -80,10 +80,13 @@ void touch_main(void)
if (s) break;
toybuf[1]='y';
}
+ tm.tm_sec = 0;
ts->tv_nsec = 0;
if (s && *s=='.' && sscanf(s, ".%2u%n", &(tm.tm_sec), &len) == 1) {
- sscanf(s += len, "%lu%n", &ts->tv_nsec, &len);
- len++;
+ if (sscanf(s += len, "%lu%n", &ts->tv_nsec, &len) == 1) {
+ s--;
+ len++;
+ } else len = 0;
} else len = 0;
}
if (len) {