Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer underflow while calculating RXWindow #1522

Open
NovaNekmit opened this issue Mar 15, 2023 · 0 comments
Open

Integer underflow while calculating RXWindow #1522

NovaNekmit opened this issue Mar 15, 2023 · 0 comments

Comments

@NovaNekmit
Copy link

The fix for #1349 (e5076e1) calculates the windows without first checking if the processing delay was longer the rx window delay.
This may causes a negative result to be passed to TimerSetValue as unsigned integer, resulting in an extremely very large timeout (close to 50 days).

    CRITICAL_SECTION_BEGIN( );
    uint32_t offset = TimerGetCurrentTime( ) - TxDoneParams.CurTime;  // this could get larger than window delays
    TimerSetValue( &MacCtx.RxWindowTimer1, MacCtx.RxWindow1Delay - offset );  // underflow can happen here
    TimerStart( &MacCtx.RxWindowTimer1 );
    TimerSetValue( &MacCtx.RxWindowTimer2, MacCtx.RxWindow2Delay - offset );  // underflow can happen here
    TimerStart( &MacCtx.RxWindowTimer2 );
    CRITICAL_SECTION_END( );

Of course this should not happen (as that means the window has been missed), but it can occur depending on processing priorities.
4.6.0 is not effected as the window delay was not calculated based on the offset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant