-
Notifications
You must be signed in to change notification settings - Fork 160
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
Fix segfault in State::serialize method #664
Fix segfault in State::serialize method #664
Conversation
I don't think we can do it this way. Cipher suite ID's are registered with IANA, and a suite ID of I'm also not entirely sure how you'd trigger this condition in practice. Though it's possible to call |
This is possible now because we don't block on Handshaking anymore right? Maybe we should return a |
Good point. That's probably why this surfaces now. Returning a |
Nice, sorry mind making that change @Danielius1922 and then should be good to merge! Mind also adding a simple test on that? I can merge and tag today then! |
Mmm, one complication, Returning a That way we could modify it so that |
@daenney The issue occured in this test case - https://github.com/plgd-dev/go-coap/pull/566/files#diff-f1064f702f8a5091e655a7a69fca82d50e0a6f095ac0d733950959310eeac4f9L161 . Going by logs the ConnectionState method gets invoked during flight1 stage. Though it seems I'll have to rework some of our types for integration with pion/dtls/v3 anyway, because we have several readers and writers running in different goroutines. For v3 this means that this can trigger multiple concurrent handshakes over the same Conn instance, which doesn't seem to be an intended use case since I get a panic on attempting to close an already closed channel ( |
Sure, let's see what I can do before my weekend starts! |
60943ff
to
0069e4a
Compare
@Danielius1922 @daenney sorry last thing! Would it be better to return Might be better to have a empty struct. Even if someone misinterprets the values that is better then crashing. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #664 +/- ##
==========================================
- Coverage 80.26% 80.09% -0.17%
==========================================
Files 101 101
Lines 5335 5355 +20
==========================================
+ Hits 4282 4289 +7
- Misses 686 695 +9
- Partials 367 371 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@Sean-Der As a user myself I would prefer a change that breaks API, but can be easily updated to new API instead of getting an unexpected segfault because of a missing nil check on a return value that has been silently changed to a pointer. |
Fair point. Since we've just done v3 we may want to avoid changing if state, ok := c.State(); !ok {
.. loop ..
} |
I think it would be ok to break major version in this case? We just did a break and this API is unusable because of it. I don’t see a way we can keep it when he has such a deficiency. Crashing or returning bad values. |
That's fair. The current behaviour of |
Nice, I will take that on today and get that out ASAP |
0069e4a
to
0aea148
Compare
The method gets invoked from public API function Conn::ConnectionState but the cipherSuite pointer member might not have been initialized yet. Invoking ConnectionState too early causes a segfault. Issue is fixed by changing the return type of Conn::ConnectionState from State to (State, bool) and returning (State{}, false) if the cipherSuite has not been set.
0aea148
to
d041552
Compare
OK, so I modified |
The method gets invoked from public API function Conn::ConnectionState but the cipherSuite pointer member might not have been initialized yet. Invoking ConnectionState too early causes a segfault. Issue is fixed by adding a nil check and returning 0 for State::CipherSuiteID if the cipherSuite has not been set.