Don't write a zero past end of toybuf with large -d value.
authorRob Landley <rob@landley.net>
Mon, 9 Sep 2013 11:50:00 +0000 (06:50 -0500)
committerRob Landley <rob@landley.net>
Mon, 9 Sep 2013 11:50:00 +0000 (06:50 -0500)
toys/posix/touch.c

index 3a65e93..4d46a16 100644 (file)
@@ -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);
       }