Re: setitimer will need a range check
- From: Michal Jaegermann <michal harddata com>
- To: John Harper <jsh unfactored org>
- Cc: sawfish-list gnome org
- Subject: Re: setitimer will need a range check
- Date: Fri, 29 Dec 2006 15:05:50 -0700
On Fri, Dec 29, 2006 at 12:41:35PM -0800, John Harper wrote:
> Hi,
>
> It's a long time since I've looked at this code, but it looks like
> this is what the fix_time function in that file is trying to achieve -
> i.e. ensure that 0 <= msecs < 1000.
Indeed, this is a miliseconds range and that would be somewhat
narrower than a microseconds range allowed by setitimer(). A small
problem is that fix_time is not doing what is advertised unless
changed in such way:
--- librep/src/timers.c~ 2002-03-01 22:22:53.000000000 -0700
+++ librep/src/timers.c 2006-12-29 14:27:41.000000000 -0700
@@ -128,7 +128,7 @@ fix_time (long *secs, long *msecs)
*msecs += 1000;
(*secs)--;
}
- while (*msecs > 1000)
+ while (*msecs >= 1000)
{
*msecs -= 1000;
(*secs)++;
> I think the change below should
> use that function to fix the bad values to setitimer, can you confirm
> that?
A quick run with fix_time modification seems to suggest that the
above would be enough. OTOH it is possible that in some other
situations out-of-range values can be passed to timers in places you
marked in your patch so applying it as well would be at least
prudent.
>
> diff -u -p -r1.15 timers.c
> --- timers.c 2 Mar 2002 05:22:53 -0000 1.15
> +++ timers.c 29 Dec 2006 20:39:56 -0000
> @@ -252,6 +252,7 @@ to re-enable it.
> t->function = fun;
> t->secs = rep_get_long_int (secs);
> t->msecs = rep_get_long_int (msecs);
> + fix_time (&t->secs, &t->msecs);
> t->next_alloc = allocated_timers;
> allocated_timers = t;
> insert_timer (t);
> @@ -290,6 +291,7 @@ duration. Otherwise, the existing values
> {
> TIMER(timer)->secs = rep_get_long_int (secs);
> TIMER(timer)->msecs = rep_get_long_int (msecs);
> + fix_time (&TIMER (timer)->secs, &TIMER (timer)->msecs);
> }
> insert_timer (TIMER(timer));
> return timer;
Michal
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]