aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-09-09 06:50:00 -0500
committerRob Landley <rob@landley.net>2013-09-09 06:50:00 -0500
commitf93d4862a92b58be01de879b18705fb1d3349bde (patch)
tree993cfb00539c132ee4fe2677943226fd72dbb183
parent94fdf492936c6ebe6074d8bf5f471823b0c6b94c (diff)
downloadtoybox-f93d4862a92b58be01de879b18705fb1d3349bde.tar.gz
Don't write a zero past end of toybuf with large -d value.
-rw-r--r--toys/posix/touch.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/toys/posix/touch.c b/toys/posix/touch.c
index 3a65e931..4d46a162 100644
--- a/toys/posix/touch.c
+++ b/toys/posix/touch.c
@@ -72,6 +72,7 @@ void touch_main(void)
putenv("TZ=UTC");
strncpy(toybuf, date, sizeof(toybuf)-1);
date = toybuf;
+ if (i > sizeof(toybuf)-1) i = sizeof(toybuf)-1;
date[i]=0;
gmtime_r(&(tv->tv_sec), &tm);
}