Fix infinite loop on s_client starttls xmpp
[openssl.git] / apps / s_client.c
index 61ad29134ba4349d2fc20a1d52e5fc6b47846ecd..9c7f45f33c507f9827a3b71c04218330d43121b2 100644 (file)
@@ -1673,11 +1673,14 @@ SSL_set_tlsext_status_ids(con, ids);
                    "xmlns='jabber:client' to='%s' version='1.0'>", host);
                seen = BIO_read(sbio,mbuf,BUFSIZZ);
                mbuf[seen] = 0;
-               while (!strstr(mbuf, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'"))
+               while (!strstr(mbuf, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'") &&
+                               !strstr(mbuf, "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\""))
                        {
-                       if (strstr(mbuf, "/stream:features>"))
-                               goto shut;
                        seen = BIO_read(sbio,mbuf,BUFSIZZ);
+
+                       if (seen <= 0)
+                               goto shut;
+
                        mbuf[seen] = 0;
                        }
                BIO_printf(sbio, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");