Fix apps/s_client.c's XMPP client
authorRichard Levitte <levitte@openssl.org>
Thu, 20 Jul 2017 19:22:31 +0000 (21:22 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 20 Jul 2017 21:26:42 +0000 (23:26 +0200)
When an error occurs during the starttls handskake, s_client gets stuck
looping around zero bytes reads, because the server won't sent anything more
after its error tag.  Shutting down on the first zero byte read fixes this.

Fixes #3980

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3981)

apps/s_client.c

index 85c1b6b579445aa1fcefe09043c7f3187ed11db2..dc467994f8e2423b5e6d6656a732215806b02ff6 100644 (file)
@@ -1667,6 +1667,8 @@ int MAIN(int argc, char **argv)
             if (strstr(mbuf, "/stream:features>"))
                 goto shut;
             seen = BIO_read(sbio, mbuf, BUFSIZZ);
+            if (seen <= 0)
+                goto shut;
             mbuf[seen] = 0;
         }
         BIO_printf(sbio,