s_client starttls: fix handling of multiline reply
authorDan Campbell <dan@ws0w.com>
Thu, 4 Apr 2019 21:15:33 +0000 (15:15 -0600)
committerPauli <paul.dale@oracle.com>
Mon, 8 Apr 2019 01:03:36 +0000 (11:03 +1000)
Fixes #8645

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8654)

(cherry picked from commit f997e456b9bd43af275aab90c727a52287467e98)

apps/s_client.c

index 4dd6e2fef4e45f111e342b831791b4ec1771e778..b85339a0b870cc397f9289f97a5798151fe9d584 100644 (file)
@@ -2253,7 +2253,7 @@ int s_client_main(int argc, char **argv)
             do {
                 mbuf_len = BIO_gets(fbio, mbuf, BUFSIZZ);
             }
-            while (mbuf_len > 3 && mbuf[3] == '-');
+            while (mbuf_len > 3 && (!isdigit(mbuf[0]) || !isdigit(mbuf[1]) || !isdigit(mbuf[2]) || mbuf[3] != ' '));
             (void)BIO_flush(fbio);
             BIO_pop(fbio);
             BIO_free(fbio);