buglwIP - A Lightweight TCP/IP stack - Bugs: bug #29769, sys_check_timeouts: sys_now() may...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #29769: sys_check_timeouts: sys_now() may overflow

Submitted by:  Simon Goldschmidt <goldsimon>
Submitted on:  Tue 04 May 2010 10:26:23 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned Release: None
lwIP version: CVS Head

Tue 04 May 2010 07:29:01 PM UTC, comment #2:

That should work on any architecture since sys_now() and 'last_time' both give u32_t values.

Fixed by adding this macro as 'LWIP_U32_DIFF' to def.h.

Thanks for the code ;-)

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Tue 04 May 2010 01:39:19 PM UTC, comment #1:

I use the following macro:

#define TIMEDIFF(a,b) (((a) >= (b)) ? ((a)-(b)) : (((a)+((b)^0xFFFFFFFF)+1)))

It's used like that:

time_diff = TIMEDIFF(sys_now(), last_time);

Seems to be the same as the proposed one and I can confirm it works (at least on a 32-bit micro).

Iordan Neshev <iordan_neshev>
Tue 04 May 2010 10:26:23 AM UTC, original submission:

For NO_SYS==1, sys_check_timeouts uses sys_now() time-difference to check for timeouts. Now when the time wraps around (after 49-something days), no more timers will get called. Possible solution:

> void
> sys_check_timeouts(void)
> {
> struct sys_timeo *tmptimeout;
> u32_t diff;
> sys_timeout_handler h;
> void *arg;
> int had_one;
> u32_t now;
> #if LWIP_DEBUG_TIMERNAMES
> const char *handler_name;
> #endif /* LWIP_DEBUG_TIMERNAMES */
>
> now = sys_now();
> if (next_timeout) {
> /* @todo: wrap around? */
> // --------- new code
> if (now < timeouts_last_time)
> diff = ( 0xFFFFFFFF - timeouts_last_time ) + now + 1 ;
> else
> // --------- end of new code
> diff = now - timeouts_last_time;
>

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by iordan_neshev (Posted a comment)
  • -unavailable- added by goldsimon (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 04 May 2010 07:29:01 PM UTCgoldsimonStatusNone=>Fixed
      Assigned toNone=>goldsimon
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1