Subject: 24.0.93; Infinite loop in GnuTLS code during Gnus nnimap-initiated SSL handshake

From: Thomas Fitzsimmons <[email-masked]>
Date: Mon, 27 Feb 2012 18:51:35 -0500

In GNU Emacs 24.0.93.7 (i686-pc-linux-gnu, GTK+ Version 2.12.12)
 of 2012-02-23
Configured using:
 `configure '--prefix=/home/fitzsim/Programs/emacs-24.0.93'
 '--x-libraries=/home/fitzsim/Programs/awesome-3.4.11/lib''
Built against: GnuTLS 3.0.8

When I attempt to connect to an Exchange server using IMAP, Emacs
sometimes enters an infinite loop in the GnuTLS code.

I can replicate it on about 50% of attempts:

1. Run:

emacs -Q

2. Evaluate:

(setq gnutls-log-level 5
      message-log-max t
      gnus-directory "~/.emacs.d/gnus/News/"
      gnus-startup-file "~/.emacs.d/gnus/.newsrc"
      gnus-secondary-select-methods
      (quote ((nnimap "<imap_server_hostname>"
                      (nnimap-server-address "<imap_server_hostname>")
                      (nnimap-server-port 993)
                      (nnimap-user "fitzsim")))))

3. Run:

M-x gnus

I've attached the *Messages* output for the passing and failing cases.
I've redacted the IMAP server name, and I had to install a patch to
limit the number of iterations of the loop to 100 so that I could copy
*Messages*.

In the failing case the server returns a non-zero-length SessionID, then
the infinite read loop is entered; when SessionID's length is 0, the
handshake succeeds and I'm greeted with the IMAP password prompt.

Thomas