mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Felix Janda <felix.janda@posteo.de>
To: musl@lists.openwall.com
Subject: [PATCH] fix futimes(fd, 0)
Date: Thu, 7 May 2015 00:10:28 +0200	[thread overview]
Message-ID: <20150506221028.GA29076@euler> (raw)

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


             reply	other threads:[~2015-05-06 22:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06 22:10 Felix Janda [this message]
2015-05-06 22:55 ` Szabolcs Nagy
2015-05-06 23:19   ` Rich Felker
2015-05-06 22:55 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150506221028.GA29076@euler \
    --to=felix.janda@posteo.de \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).