summaryrefslogtreecommitdiff
path: root/coreutils/touch.c
diff options
context:
space:
mode:
authorDenys Vlasenko2009-11-29 19:40:36 +0100
committerDenys Vlasenko2009-11-29 19:40:36 +0100
commitdcbfaba264df2f9f07e53f77e8178f5bfc7ae88e (patch)
treeb5dfaa3715ded4f3c9a676b6cf636ad50bf04c9d /coreutils/touch.c
parentbf22475e9552b08feb31d40250ab293d2fd98234 (diff)
downloadbusybox-dcbfaba264df2f9f07e53f77e8178f5bfc7ae88e.zip
busybox-dcbfaba264df2f9f07e53f77e8178f5bfc7ae88e.tar.gz
fix improper utimes usage
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/touch.c')
-rw-r--r--coreutils/touch.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c
index f670b7f..be2d2f9 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -54,8 +54,8 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
# endif
char *reference_file = NULL;
char *date_str = NULL;
- struct timeval timebuf;
- timebuf.tv_usec = 0;
+ struct timeval timebuf[2];
+ timebuf[1].tv_usec = timebuf[0].tv_usec = 0;
#else
# define reference_file NULL
# define date_str NULL
@@ -84,7 +84,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
if (reference_file) {
struct stat stbuf;
xstat(reference_file, &stbuf);
- timebuf.tv_sec = stbuf.st_mtime;
+ timebuf[1].tv_sec = timebuf[0].tv_sec = stbuf.st_mtime;
}
if (date_str) {
@@ -100,11 +100,11 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
tm_time.tm_isdst = -1; /* Be sure to recheck dst */
t = validate_tm_time(date_str, &tm_time);
- timebuf.tv_sec = t;
+ timebuf[1].tv_sec = timebuf[0].tv_sec = t;
}
do {
- if (utimes(*argv, reference_file ? &timebuf : NULL)) {
+ if (utimes(*argv, reference_file ? timebuf : NULL)) {
if (errno == ENOENT) { /* no such file */
if (opts) { /* creation is disabled, so ignore */
continue;
@@ -115,7 +115,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
);
if ((fd >= 0) && !close(fd)) {
if (reference_file)
- utimes(*argv, &timebuf);
+ utimes(*argv, timebuf);
continue;
}
}