Commit graph

6 commits

Author SHA1 Message Date
John Millikin
0d7a60a1cc
Fix a crash due to out-of-order garbage collection of Session values.
GnuTLS has separate initialization and deinitialization procedures for
global and per-session state. Previously, haskell-gnutls used Haskell's
garbage collector (via ForeignPtr) to manage these separate states by
creating a dummy GlobalState type representing an initialized global
state. The Session type contained ForeignPtrs to the global and session
state, with the idea that GC would collect them both at the same time
(albeit in non-determinstic order).

It turns out that session deinitialization *requires* an initialized
global state, and calling gnutls_deinit() after gnutls_global_deinit()
can cause a crash.

This patch solves the crash by removing the GlobalState ForeignPtr hack,
and ensuring that gnutls_global_deinit() is always called after
gnutls_deinit().

Originally reported by Keven McKenzie and Joey Hess.
2013-09-07 12:32:39 -07:00
John Millikin
777d600326
After setting credentials, save a reference to the gnutls credentials
struct to keep them alive for the duration of the session.

Fixes a potential crash when opening connections, reported by Joey Hess.
2012-10-26 19:01:52 -07:00
John Millikin
5001417174
Minor cleanups. Remove maximum version of "transformers" dependency. 2012-05-13 14:28:58 -07:00
John Millikin
05137fd023
Export 'rehandshake'. 2012-02-23 18:33:43 -08:00
John Millikin
c51832cc43
Fix some compilation errors. 2012-02-23 18:33:26 -08:00
John Millikin
c36fdda7d8
Clean up the Cabal file, and move library source to lib/. 2012-02-23 18:30:29 -08:00
Renamed from Network/Protocol/TLS/GNU.hs (Browse further)