Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200301083753.GC2769@voyager>
Date: Sun, 1 Mar 2020 09:37:53 +0100
From: Markus Wichmann <nullplan@....net>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] musl: lutimes: Add checks for input parameters

On Sun, Mar 01, 2020 at 02:57:30PM +0800, Liu Jie wrote:
> For the input parameter struct timeval tv, need to
> determine whether it is invalid inputs.
>

Why? lutimes() is a Linux-specific function, so the manpage is as close
to a specification as you're ever going to get, and it does not specify
an EINVAL return.

Adding the NULL pointer check, though, is probably justified, given that
the manpage states that lutimes() acts "in the same way as utimes(2)"
(with an irrelevant exception afterwards), and utimes() allows for a
NULL tv input.

The kernel itself also checks the input values again. While I usually am
in favor of failing faster, in this case I fail to see the benefit.
Especially since you're not testing for the one case that could make the
kernel accept a timestamp that was invalid on input: An overflowing one.
But you don't test for the upper limit.

Oh, and the seconds are allowed to be negative. If someone wants to set
a timestamp from before 1970, the libc is the wrong place to stop them.
If such dates are invalid from your application's perspective, filter
that there.

Have a nice Sunday,
Markus

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.