Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Thu, 7 May 2015 00:10:28 +0200
From: Felix Janda <felix.janda@...teo.de>
To: musl@...ts.openwall.com
Subject: [PATCH] fix futimes(fd, 0)

Pass on 0 to futimens without trying to dereference it.
---
 src/legacy/futimes.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/legacy/futimes.c b/src/legacy/futimes.c
index d81d83a..21db18b 100644
--- a/src/legacy/futimes.c
+++ b/src/legacy/futimes.c
@@ -4,10 +4,12 @@
 
 int futimes(int fd, const struct timeval tv[2])
 {
-	struct timespec times[2];
-	times[0].tv_sec  = tv[0].tv_sec;
-	times[0].tv_nsec = tv[0].tv_usec * 1000;
-	times[1].tv_sec  = tv[1].tv_sec;
-	times[1].tv_nsec = tv[1].tv_usec * 1000;
-	return futimens(fd, times);
+	if (tv) {
+		struct timespec times[2];
+		times[0].tv_sec  = tv[0].tv_sec;
+		times[0].tv_nsec = tv[0].tv_usec * 1000;
+		times[1].tv_sec  = tv[1].tv_sec;
+		times[1].tv_nsec = tv[1].tv_usec * 1000;
+		return futimens(fd, times);
+	} else return futimens(fd, 0);
 }
-- 
2.3.6

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.