mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] fix futimes(fd, 0)
@ 2015-05-06 22:10 Felix Janda
  2015-05-06 22:55 ` Szabolcs Nagy
  2015-05-06 22:55 ` Rich Felker
  0 siblings, 2 replies; 4+ messages in thread
From: Felix Janda @ 2015-05-06 22:10 UTC (permalink / raw)
  To: musl

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-06 23:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-06 22:10 [PATCH] fix futimes(fd, 0) Felix Janda
2015-05-06 22:55 ` Szabolcs Nagy
2015-05-06 23:19   ` Rich Felker
2015-05-06 22:55 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).