On Sat, Jan 11, 2020 at 09:43:04PM +0100, Alexander Bluhm wrote:
> On Thu, Jan 09, 2020 at 04:10:03PM +0100, Martin Pieuchot wrote:
> > case SO_RCVTIMEO:
> > {
> > struct timeval tv;
> > - int val;
> > + uint64_t nsecs;
> >
> > if (m == NULL || m->m_len < sizeof (tv))
> > return (EINVAL);
> > memcpy(&tv, mtod(m, struct timeval *), sizeof tv);
> > - val = tvtohz(&tv);
> > - if (val > USHRT_MAX)
> > - return (EDOM);
> > -
> > + nsecs = TIMEVAL_TO_NSEC(&tv);
>
> There was a range check before, I would like to keep that.
> And tv is user data, we should be more paranoid.
> Something like this, or a new macro TIMEVAL_ISVALID() ?
See timerisvalid(3), merged about a year ago.