From f93d4862a92b58be01de879b18705fb1d3349bde Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 9 Sep 2013 06:50:00 -0500 Subject: Don't write a zero past end of toybuf with large -d value. --- toys/posix/touch.c | 1 + 1 file changed, 1 insertion(+) 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); } -- cgit v1.2.3