changeset 1062:3c744d5f0765 draft

Don't write a zero past end of toybuf with large -d value.
author Rob Landley <rob@landley.net>
date Mon, 09 Sep 2013 06:50:00 -0500
parents ed2694ccf2ae
children 51f0dda223b8
files toys/posix/touch.c
diffstat 1 files changed, 1 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/toys/posix/touch.c	Mon Sep 09 05:52:49 2013 -0500
+++ b/toys/posix/touch.c	Mon Sep 09 06:50:00 2013 -0500
@@ -72,6 +72,7 @@
         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);
       }