Subject: bug#13706: 24.3.50; network-stream-command may return nil, not always a string

From: Didier Verna <[email-masked]>
Date: Wed, 13 Feb 2013 10:54:27 +0100

network-stream-get-response returns nil if the server connection is
lost, hence network-stream-command does the same. There was one instance
of a blind string-match against the return value which would fail with a
STRINGP NIL error from time to time.

The attached patch fixes this.

2013-02-13  Didier Verna  <[email-masked]>

	* net/network-stream.el (network-stream-open-starttls): Check that
	the response to the starttls-command is not nil before
	string-match'ing it.

diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el
index 8cf9ec6..fd21997 100644
--- a/lisp/net/network-stream.el
+++ b/lisp/net/network-stream.el
@@ -262,8 +262,9 @@ STARTTLS upgrades even if Emacs doesn't have built-in TLS functionality.
 	;; EHLO for SMTP.
 	(when (plist-get parameters :always-query-capabilities)
 	  (network-stream-command stream capability-command eo-capa)))
-      (when (string-match success-string
-			  (network-stream-command stream starttls-command eoc))
+      (when (let ((response
+		   (network-stream-command stream starttls-command eoc)))
+	      (and response (string-match success-string response)))
 	;; The server said it was OK to begin STARTTLS negotiations.
 	(if builtin-starttls
 	    (let ((cert (network-stream-certificate host service parameters)))

-- 
Resistance is futile. You will be jazzimilated.

Scientific site:   http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com

EPITA/LRDE, 14-16 rue Voltaire, 94276 Le Kremlin-Bicªtre, France
Tel. +33 (0)1 44 08 01 85       Fax. +33 (0)1 53 14 59 22