dtls.c, netq.c: consider 32bit time overflow.#131
Merged
obgm merged 1 commit intoeclipse-tinydtls:developfrom May 23, 2022
Merged
dtls.c, netq.c: consider 32bit time overflow.#131obgm merged 1 commit intoeclipse-tinydtls:developfrom
obgm merged 1 commit intoeclipse-tinydtls:developfrom
Conversation
boaks
commented
Mar 30, 2022
dtls_time.h
Outdated
| void dtls_clock_init(void); | ||
| void dtls_ticks(dtls_tick_t *t); | ||
|
|
||
| // see https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYTStJg1AB9U8lJL6yAngGVG6AMKpaAVxYMJG0g4AyeBkwAOXcAI0xiEAA2UgAHVAVCWwZnNw8vOISkgX9AkJZwyJjLTGtkoQImYgJU908ubxKygQqqglzgsIjoi0rq2vSG3raO/MLogEoLVFdiZHYOAFIAJgBmAOQ3LABqRdXHBQJ8VAA6BD3sRY0AQRX1hk3XHb2Do4CCM4ur25u7rBpAtsACpBYwAeQAYhChNggdsIABWDQTb7fAgAT1imH%2B21c7wAHMYCNtNqhkABrIl4NhEvYAIVRN3e2xYTACEAAbqg8OgUQB2Bk3bbC7Zcgw2egk2hkyk2GnE4l7AAi2w09O%2BItFLiYEswUplVPl2wYu1WKrVq0F101aAYh31FMNmCJLKYwDwyGMqCoVCUirN8KgpMdcudBAmAD9kabLqtsNsuCjLRqRYsBSnhczkKbzeqhSL%2BMR4cy8DnVaa6dtSy9tqsNBbK9Xlgzm9t%2BVbNZqAPRd0sAdzotG2qA5ESo0r7VcEqG2xMM6GNu3zndnZbweetK8Xyqr2wAtMDQZDobCN1uq1RA8HZdSwxMIKz3Z7vb7MIrWyaD%2BHTY5XU%2BvT6frthm54kisLYMsmy6dmmSogbBIGxMQ7xUBAKzLNKqCxAmJIgCsCILosCKOAw6GkCSSYdqmfJwb80FplRmaCCSZYNiBhbFsx1YBhoFa7jWdYNvxzbgW2DE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OprTMhjMqEQCQDMAgsRLb0P4XzQRZiSB6FETHCR0gpFKBkZrcJTBIncAZsTWJBDeAXzBJbLpxJvQZOvrfe%2Bj9n75LfoA3mERf6rETIU%2BmUDSAIEwEwLAkQIDROqSAWpSyKYcGIU0y5xSognEkJILBqx4r4gRFg/ECDKkcHLnUwhziIHo0hcsM%2BsKPmkO%2BaQRqiQ7CSCAA%3D |
Contributor
Author
There was a problem hiding this comment.
Maybe, I better remove the "huge" link ...
There was a problem hiding this comment.
godbolt also has short links
https://godbolt.org/z/YchexKaeT
dd8affc to
9fb395d
Compare
kfessel
reviewed
Mar 30, 2022
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) |
There was a problem hiding this comment.
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)
Contributor
Author
There was a problem hiding this comment.
Thanks for pointing to that.
Fixes issue: eclipse-tinydtls#125 Signed-off-by: Achim Kraus <achim.kraus@bosch.io>
9fb395d to
cde751a
Compare
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uses proposal in issue #125 to fix a 32bit overflow.
Fixes issue: #125
Signed-off-by: Achim Kraus achim.kraus@bosch.io