* [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
* Re: [PATCH] fix futimes(fd, 0)
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
1 sibling, 1 reply; 4+ messages in thread
From: Szabolcs Nagy @ 2015-05-06 22:55 UTC (permalink / raw)
To: musl
* Felix Janda <felix.janda@posteo.de> [2015-05-07 00:10:28 +0200]:
> Pass on 0 to futimens without trying to dereference it.
is there a reason to accept 0 argument?
there are other cases when the libc has to do fixups
to the passed arguments and it dereferences the pointer
which should be valid
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fix futimes(fd, 0)
2015-05-06 22:55 ` Szabolcs Nagy
@ 2015-05-06 23:19 ` Rich Felker
0 siblings, 0 replies; 4+ messages in thread
From: Rich Felker @ 2015-05-06 23:19 UTC (permalink / raw)
To: musl
On Thu, May 07, 2015 at 12:55:19AM +0200, Szabolcs Nagy wrote:
> * Felix Janda <felix.janda@posteo.de> [2015-05-07 00:10:28 +0200]:
> > Pass on 0 to futimens without trying to dereference it.
>
> is there a reason to accept 0 argument?
>
> there are other cases when the libc has to do fixups
> to the passed arguments and it dereferences the pointer
> which should be valid
Yes, see the man page:
http://man7.org/linux/man-pages/man3/futimes.3.html
It defers to utimes for the actual behavior, which is a standard
(albeit deprecated) function, and has specified behavior for the null
pointer case.
Rich
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fix futimes(fd, 0)
2015-05-06 22:10 [PATCH] fix futimes(fd, 0) Felix Janda
2015-05-06 22:55 ` Szabolcs Nagy
@ 2015-05-06 22:55 ` Rich Felker
1 sibling, 0 replies; 4+ messages in thread
From: Rich Felker @ 2015-05-06 22:55 UTC (permalink / raw)
To: musl
On Thu, May 07, 2015 at 12:10:28AM +0200, Felix Janda wrote:
> Pass on 0 to futimens without trying to dereference it.
> ---
> src/legacy/futimes.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
Thanks. I committed a simplified version.
Rich
^ 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).