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

dtls.c, netq.c: consider 32bit time overflow. #131

Merged
merged 1 commit into from
May 23, 2022

Conversation

boaks
Copy link
Contributor

@boaks boaks commented Mar 29, 2022

Uses proposal in issue #125 to fix a 32bit overflow.

Fixes issue: #125

Signed-off-by: Achim Kraus achim.kraus@bosch.io

dtls_time.h Outdated
@@ -73,6 +75,11 @@ typedef clock_time_t dtls_tick_t;
void dtls_clock_init(void);
void dtls_ticks(dtls_tick_t *t);

// see https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYTStJg1AB9U8lJL6yAngGVG6AMKpaAVxYMJG0g4AyeBkwAOXcAI0xiEAA2UgAHVAVCWwZnNw8vOISkgX9AkJZwyJjLTGtkoQImYgJU908ubxKygQqqglzgsIjoi0rq2vSG3raO/MLogEoLVFdiZHYOAFIAJgBmAOQ3LABqRdXHBQJ8VAA6BD3sRY0AQRX1hk3XHb2Do4CCM4ur25u7rBpAtsACpBYwAeQAYhChNggdsIABWDQTb7fAgAT1imH%2B21c7wAHMYCNtNqhkABrIl4NhEvYAIVRN3e2xYTACEAAbqg8OgUQB2Bk3bbC7Zcgw2egk2hkyk2GnE4l7AAi2w09O%2BItFLiYEswUplVPl2wYu1WKrVq0F101aAYh31FMNmCJLKYwDwyGMqCoVCUirN8KgpMdcudBAmAD9kabLqtsNsuCjLRqRYsBSnhczkKbzeqhSL%2BMR4cy8DnVaa6dtSy9tqsNBbK9Xlgzm9t%2BVbNZqAPRd0sAdzotG2qA5ESo0r7VcEqG2xMM6GNu3zndnZbweetK8Xyqr2wAtMDQZDobCN1uq1RA8HZdSwxMIKz3Z7vb7MIrWyaD%2BHTY5XU%2BvT6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R2GBFoFwlqDjaG0AAJLoBALEJg3D6CkD7M7WIPsT4cFBvg8mF8gkhMRn/aShAEDbCvjfO%2BD8n4Ji4K/cBZDoHY1xgTMp2N9CcDwd7JEcTz7OOprTMhjMqEQCQDMAgsRLb0P4XzQRZiSB6FETHCR0gpFKBkZrcJTBIncAZsTWJBDeAXzBJbLpxJvQZOvrfe%2Bj9n75LfoA3mERf6rETIU%2BmUDSAIEwEwLAkQIDROqSAWpSyKYcGIU0y5xSognEkJILBqx4r4gRFg/ECDKkcHLnUwhziIHo0hcsM%2BsKPmkO%2BaQRqiQ7CSCAA%3D
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, I better remove the "huge" link ...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

godbolt also has short links
https://godbolt.org/z/YchexKaeT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better.

@boaks boaks force-pushed the fix_32bit_time_overflow branch 2 times, most recently from dd8affc to 9fb395d Compare March 30, 2022 11:25
dtls_time.h Outdated
/* see https://godbolt.org/z/YchexKaeT */
#define DTLS_OFFSET_TIME (((clock_time_t)~0) >> 1)
/** Checks if A is before (or equal) B. Considers 32 bit time overflow */
#define DTLS_IS_BEFORE_TIME(A, B) ((DTLS_OFFSET_TIME + (B)-(A)) >= DTLS_OFFSET_TIME)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define DTLS_IS_BEFORE_TIME(A, B) ((DTLS_OFFSET_TIME + (B)-(A)) >= DTLS_OFFSET_TIME)
#define DTLS_IS_BEFORE_TIME(A, B) ((clock_time_t)(DTLS_OFFSET_TIME + (B)-(A)) >= DTLS_OFFSET_TIME)

that cast is needed (check with godbolt)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing to that.

Fixes issue: eclipse#125

Signed-off-by: Achim Kraus <achim.kraus@bosch.io>
@obgm
Copy link
Contributor

obgm commented May 23, 2022

Nice, thanks @boaks and @kfessel

@obgm obgm merged commit c3754dc into eclipse:develop May 23, 2022
@boaks boaks deleted the fix_32bit_time_overflow branch May 23, 2022 13:27
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

Successfully merging this pull request may close these issues.

3 participants