After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 697754 - gtlsconnection-gnutls crash if trying to do a read/write during a async handshake
gtlsconnection-gnutls crash if trying to do a read/write during a async hands...
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: network
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 725423 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-04-10 18:56 UTC by Olivier Crête
Modified: 2017-11-15 12:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tls: Test for crash when read or write is called during an async handshake (2.99 KB, patch)
2013-04-10 18:56 UTC, Olivier Crête
none Details | Review
gtlsconnection-gnutls: Only finish implicit handshake if handshake is implicit (899 bytes, patch)
2013-04-10 18:56 UTC, Olivier Crête
accepted-commit_now Details | Review
gtlsconnection-gnutls: Only finish implicit handshake if handshake is implicit (3.70 KB, patch)
2013-04-10 21:58 UTC, Olivier Crête
none Details | Review
gtlsconnection-gnutls: Only finish implicit handshake if handshake is implicit (3.72 KB, patch)
2013-04-10 22:16 UTC, Olivier Crête
accepted-commit_now Details | Review

Description Olivier Crête 2013-04-10 18:56:27 UTC
If one calls g_tls_connection_handshake_async() and then after the handshake has finished, but before the callback has been called, one calls read or write, it will get confused and try to complete the handshake as if it had been an implicit handshake.

With test and patch!
Comment 1 Olivier Crête 2013-04-10 18:56:43 UTC
Created attachment 241201 [details] [review]
tls: Test for crash when read or write is called during an async handshake
Comment 2 Olivier Crête 2013-04-10 18:56:46 UTC
Created attachment 241202 [details] [review]
gtlsconnection-gnutls: Only finish implicit handshake if handshake is implicit
Comment 3 Dan Winship 2013-04-10 21:28:29 UTC
Comment on attachment 241202 [details] [review]
gtlsconnection-gnutls: Only finish implicit handshake if handshake is implicit

looks good, but please squash the two patches together (or commit the fix first and the test second) so that there's not a commit where the tests don't pass
Comment 4 Olivier Crête 2013-04-10 21:58:27 UTC
Created attachment 241212 [details] [review]
gtlsconnection-gnutls: Only finish implicit handshake if handshake is implicit

Also add a test to prevent regressions, this test tries to do a async handshake,
and waits for the actual handshake to finish, but before allowing the callback to happen
it tries to do a write.
Comment 5 Olivier Crête 2013-04-10 22:16:09 UTC
Created attachment 241213 [details] [review]
gtlsconnection-gnutls: Only finish implicit handshake if handshake is implicit

With extra g_test_bug(), also please triple check that my fix is correct, I'm not sure I understand all of the possible interactions.
Comment 6 Dan Winship 2013-04-15 13:57:58 UTC
Comment on attachment 241213 [details] [review]
gtlsconnection-gnutls: Only finish implicit handshake if handshake is implicit

yeah, pretty sure it's right. i need to go through and re-figure all this out and improve the comment inside the GTlsConnectionGnutlsPrivate definition.

I'm not so convinced of its correctness that I'd want to land it in today's release though. So, commit it to master, and if it doesn't cause problems, we'll get it into 3.8.2
Comment 7 Olivier Crête 2013-04-15 19:07:52 UTC
Pushed into the master branch
Comment 8 Philip Withnall 2017-11-15 12:56:19 UTC
*** Bug 725423 has been marked as a duplicate of this bug. ***