tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Fixing settime1() to reject invalid struct timespec ?
On Wed, Sep 02, 2009 at 07:31:15AM +0000, David Holland wrote:
> On Mon, Aug 31, 2009 at 05:42:42PM +0200, Nicolas Joly wrote:
> > + if (ts->tv_sec < 0 || ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000)
> > + return EINVAL;
> > +
>
> Rejecting negative tv_sec seems like a mistake - what if you want for
> some reason to set the date to 1968?
Nice catch ! Next try ...
Index: sys/kern/kern_time.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_time.c,v
retrieving revision 1.160
diff -u -p -r1.160 kern_time.c
--- sys/kern/kern_time.c 29 Mar 2009 19:21:19 -0000 1.160
+++ sys/kern/kern_time.c 2 Sep 2009 10:20:33 -0000
@@ -134,6 +134,9 @@ settime1(struct proc *p, const struct ti
struct timespec delta, now;
int s;
+ if (ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000)
+ return EINVAL;
+
/* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
s = splclock();
nanotime(&now);
--
Nicolas Joly
Biological Software and Databanks.
Institut Pasteur, Paris.
Home |
Main Index |
Thread Index |
Old Index