mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Markus Wichmann <nullplan@gmx.net>
To: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] musl: lutimes: Add checks for input parameters
Date: Sun, 1 Mar 2020 09:37:53 +0100	[thread overview]
Message-ID: <20200301083753.GC2769@voyager> (raw)
In-Reply-To: <20200301065730.146013-1-liujie1@huawei.com>

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

      parent reply	other threads:[~2020-03-01  8:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-01  6:57 Liu Jie
2020-03-01  7:17 ` Rich Felker
2020-03-01 20:37   ` Samuel Holland
2020-03-01 20:39     ` Rich Felker
2020-03-20 19:54       ` Rich Felker
2020-03-01  8:37 ` Markus Wichmann [this message]

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=20200301083753.GC2769@voyager \
    --to=nullplan@gmx.net \
    --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).