From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7569 Path: news.gmane.org!not-for-mail From: Felix Janda Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] fix futimes(fd, 0) Date: Thu, 7 May 2015 00:10:28 +0200 Message-ID: <20150506221028.GA29076@euler> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1430950260 4713 80.91.229.3 (6 May 2015 22:11:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 May 2015 22:11:00 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7582-gllmg-musl=m.gmane.org@lists.openwall.com Thu May 07 00:10:57 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Yq7Wq-0003zn-7W for gllmg-musl@m.gmane.org; Thu, 07 May 2015 00:10:56 +0200 Original-Received: (qmail 28664 invoked by uid 550); 6 May 2015 22:10:53 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 28629 invoked from network); 6 May 2015 22:10:50 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:7569 Archived-At: 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